For problem statement at 1000-1999/1000-1099/1070-1079/1070/problemJ.txt this is a correct solution, but verifier at 1000-1999/1000-1099/1070-1079/1070/verifierJ.go ends with All tests passed can you fix the verifier? package main
import (
"io"
"os"
"strconv"
)
func main() {
buf, _ := io.ReadAll(os.Stdin)
pos := 0
nextInt := func() int {
for pos < len(buf) && (buf[pos] < '0' || buf[pos] > '9') {
pos++
}
if pos >= len(buf) {
return 0
}
res := 0
for pos < len(buf) && buf[pos] >= '0' && buf[pos] <= '9' {
res = res*10 + int(buf[pos]-'0')
pos++
}
return res
}
t := nextInt()
if t == 0 {
return
}
var dp []uint64
counts := make([]int, 26)
out := make([]byte, 0, 1024*1024)
for tc := 0; tc < t; tc++ {
n := nextInt()
m := nextInt()
k := nextInt()
for i := 0; i < 26; i++ {
counts[i] = 0
}
for i := 0; i < k; {
if pos >= len(buf) {
break
}
if buf[pos] >= 'A' && buf[pos] <= 'Z' {
counts[buf[pos]-'A']++
i++
}
pos++
}
maxDpLen := (k / 64) + 1
if cap(dp) < maxDpLen {
dp = make([]uint64, maxDpLen)
}
var ans int64 = 2e18
computedZero := false
for X := 0; X < 26; X++ {
if counts[X] == 0 {
if computedZero {
continue
}
computedZero = true
}
cX := counts[X]
SRem := k - cX
dpLen := (SRem / 64) + 1
dpSlice := dp[:dpLen]
for i := 0; i < dpLen; i++ {
dpSlice[i] = 0
}
dpSlice[0] = 1
for i := 0; i < 26; i++ {
if i == X || counts[i] == 0 {
continue
}
shift := counts[i]
words := shift / 64
bits := shift % 64
for j := dpLen - 1; j >= words; j-- {
var val uint64
if bits == 0 {
val = dpSlice[j-words]
} else {
val = dpSlice[j-words] << bits
if j-words-1 >= 0 {
val |= dpSlice[j-words-1] >> (64 - bits)
}
}
dpSlice[j] |= val
}
}
minS := n - cX
if minS < 0 {
minS = 0
}
maxS := k - m
if maxS > SRem {
maxS = SRem
}
for sum := minS; sum <= maxS; sum++ {
if (dpSlice[sum/64] & (uint64(1) << (sum % 64))) != 0 {
nX := n - sum
if nX < 0 {
nX = 0
}
mX := m - SRem + sum
if mX < 0 {
mX = 0
}
cost := int64(nX) * int64(mX)
if cost < ans {
ans = cost
}
}
}
}
out = append(out, strconv.FormatInt(ans, 10)...)
out = append(out, '\n')
}
os.Stdout.Write(out)
}