For problem statement at 2000-2999/2000-2099/2030-2039/2033/problemC.txt this is a correct solution, but verifier at 2000-2999/2000-2099/2030-2039/2033/verifierC.go ends with All 203 tests passed can you fix the verifier? package main
import (
"bufio"
"fmt"
"os"
)
type FastScanner struct {
r *bufio.Reader
}
func NewFastScanner() *FastScanner {
return &FastScanner{r: bufio.NewReader(os.Stdin)}
}
func (fs *FastScanner) NextInt() int {
sign := 1
val := 0
c, _ := fs.r.ReadByte()
for (c < '0' || c > '9') && c != '-' {
c, _ = fs.r.ReadByte()
}
if c == '-' {
sign = -1
c, _ = fs.r.ReadByte()
}
for c >= '0' && c <= '9' {
val = val*10 + int(c-'0')
c, _ = fs.r.ReadByte()
}
return val * sign
}
func eq(a, b int) int {
if a == b {
return 1
}
return 0
}
func main() {
in := NewFastScanner()
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
t := in.NextInt()
for ; t > 0; t-- {
n := in.NextInt()
a := make([]int, n)
for i := 0; i < n; i++ {
a[i] = in.NextInt()
}
m := n / 2
x := make([]int, m)
y := make([]int, m)
for i := 0; i < m; i++ {
x[i] = a[i]
y[i] = a[n-1-i]
}
dp0, dp1 := 0, 0
for i := 0; i+1 < m; i++ {
xi, yi := x[i], y[i]
xj, yj := x[i+1], y[i+1]
c00 := eq(xi, xj) + eq(yi, yj)
c01 := eq(xi, yj) + eq(yi, xj)
// c10 == c01, c11 == c00
n0 := dp0 + c00
if v := dp1 + c01; v < n0 {
n0 = v
}
n1 := dp0 + c01
if v := dp1 + c00; v < n1 {
n1 = v
}
dp0, dp1 = n0, n1
}
ans := dp0
if dp1 < ans {
ans = dp1
}
if n%2 == 0 {
if m > 0 {
ans += eq(x[m-1], y[m-1])
}
} else {
c := a[m]
if m > 0 {
ans += eq(x[m-1], c) + eq(y[m-1], c)
}
}
fmt.Fprintln(out, ans)
}
}