← Home
For problem statement at 1000-1999/1100-1199/1100-1109/1102/problemD.txt this is a correct solution, but verifier at 1000-1999/1100-1199/1100-1109/1102/verifierD.go ends with All tests passed can you fix the verifier? ```go
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(in, &n)
	var s string
	fmt.Fscan(in, &s)

	b := []byte(s)
	cnt := [3]int{}
	for _, ch := range b {
		cnt[ch-'0']++
	}
	target := n / 3

	need := func(c int) int { return target - cnt[c] }

	replace := func(i int, to byte) {
		from := int(b[i] - '0')
		t := int(to - '0')
		if from == t {
			return
		}
		cnt[from]--
		cnt[t]++
		b[i] = to
	}

	for i := 0; i < n; i++ {
		c := int(b[i] - '0')
		if c == 0 {
			continue
		}
		if cnt[c] > target {
			if need(0) > 0 {
				replace(i, '0')
			} else if c == 2 && need(1) > 0 {
				replace(i, '1')
			}
		}
	}

	for i := n - 1; i >= 0; i-- {
		c := int(b[i] - '0')
		if c == 2 {
			continue
		}
		if cnt[c] > target {
			if need(2) > 0 {
				replace(i, '2')
			} else if c == 0 && need(1) > 0 {
				replace(i, '1')
			}
		}
	}

	fmt.Print(string(b))
}
```