For problem statement at 2000-2999/2000-2099/2080-2089/2085/problemB.txt this is a correct solution, but verifier at 2000-2999/2000-2099/2080-2089/2085/verifierB.go ends with All 120 tests passed. can you fix the verifier? package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var t int
fmt.Fscan(reader, &t)
for tc := 0; tc < t; tc++ {
var n int
fmt.Fscan(reader, &n)
a := make([]int, n)
z := 0
for i := 0; i < n; i++ {
fmt.Fscan(reader, &a[i])
if a[i] == 0 {
z++
}
}
type Op struct{ l, r int }
ops := make([]Op, 0, n)
for z > 0 {
idx := -1
for i := 0; i < len(a)-1; i++ {
if a[i] == 0 && a[i+1] == 0 {
idx = i
break
}
}
if idx == -1 {
for i := 0; i < len(a)-1; i++ {
if (a[i] == 0 && a[i+1] != 0) || (a[i] != 0 && a[i+1] == 0) {
idx = i
break
}
}
}
mex := 1
if a[idx] == 0 && a[idx+1] == 1 {
mex = 2
} else if a[idx] == 1 && a[idx+1] == 0 {
mex = 2
}
ops = append(ops, Op{idx + 1, idx + 2})
if a[idx] == 0 {
z--
}
if a[idx+1] == 0 {
z--
}
a[idx] = mex
a = append(a[:idx+1], a[idx+2:]...)
}
if len(a) > 1 {
ops = append(ops, Op{1, len(a)})
}
fmt.Fprintln(writer, len(ops))
for _, op := range ops {
fmt.Fprintln(writer, op.l, op.r)
}
}
}