For problem statement at 1000-1999/1800-1899/1870-1879/1872/problemE.txt this is a correct solution, but verifier at 1000-1999/1800-1899/1870-1879/1872/verifierE.go ends with case 2 failed
input:
2
5
2 87 74 28 75
10111
6
1 4 5
1 5 5
1 5 5
1 2 2
2 1
2 1
6
20 81 62 78 65 29
010110
2
1 5 6
2 0
expected:
31 31
107
got:
31
31
107
exit status 1 can you fix the verifier? package main
import (
"fmt"
"io"
"os"
"strconv"
"strings"
)
func main() {
data, _ := io.ReadAll(os.Stdin)
idx := 0
readInt := func() int {
for idx < len(data) && (data[idx] == ' ' || data[idx] == '\n' || data[idx] == '\r' || data[idx] == '\t') {
idx++
}
sign := 1
if data[idx] == '-' {
sign = -1
idx++
}
val := 0
for idx < len(data) && data[idx] >= '0' && data[idx] <= '9' {
val = val*10 + int(data[idx]-'0')
idx++
}
return val * sign
}
readString := func() string {
for idx < len(data) && (data[idx] == ' ' || data[idx] == '\n' || data[idx] == '\r' || data[idx] == '\t') {
idx++
}
start := idx
for idx < len(data) && data[idx] != ' ' && data[idx] != '\n' && data[idx] != '\r' && data[idx] != '\t' {
idx++
}
return string(data[start:idx])
}
t := readInt()
var out strings.Builder
for ; t > 0; t-- {
n := readInt()
a := make([]int, n+1)
px := make([]int, n+1)
for i := 1; i <= n; i++ {
a[i] = readInt()
px[i] = px[i-1] ^ a[i]
}
s := readString()
xr0, xr1 := 0, 0
for i := 1; i <= n; i++ {
if s[i-1] == '0' {
xr0 ^= a[i]
} else {
xr1 ^= a[i]
}
}
q := readInt()
for ; q > 0; q-- {
tp := readInt()
if tp == 1 {
l := readInt()
r := readInt()
seg := px[r] ^ px[l-1]
xr0 ^= seg
xr1 ^= seg
} else {
g := readInt()
if g == 0 {
out.WriteString(strconv.Itoa(xr0))
} else {
out.WriteString(strconv.Itoa(xr1))
}
out.WriteByte('\n')
}
}
}
fmt.Print(out.String())
}