For problem statement at 1000-1999/1800-1899/1890-1899/1898/problemE.txt this is a correct solution, but verifier at 1000-1999/1800-1899/1890-1899/1898/verifierE.go ends with case 20 failed: expected NO got YES
input:
1
5 3
cvilj
vlj
exit status 1 can you fix the verifier? package main
import (
"bytes"
"io"
"os"
)
func main() {
data, _ := io.ReadAll(os.Stdin)
p := 0
nextInt := func() int {
for p < len(data) && data[p] <= ' ' {
p++
}
v := 0
for p < len(data) && data[p] > ' ' {
v = v*10 + int(data[p]-'0')
p++
}
return v
}
nextString := func() string {
for p < len(data) && data[p] <= ' ' {
p++
}
start := p
for p < len(data) && data[p] > ' ' {
p++
}
return string(data[start:p])
}
tc := nextInt()
var out bytes.Buffer
for ; tc > 0; tc-- {
_ = nextInt()
_ = nextInt()
s := nextString()
t := nextString()
var pos [26][]int
for i := 0; i < len(s); i++ {
c := int(s[i] - 'a')
pos[c] = append(pos[c], i+1)
}
var idx [26]int
var lb [26]int
ok := true
for i := 0; i < len(t); i++ {
c := int(t[i] - 'a')
j := idx[c]
list := pos[c]
for j < len(list) && list[j] <= lb[c] {
j++
}
if j == len(list) {
ok = false
break
}
chosen := list[j]
idx[c] = j + 1
for d := 0; d < c; d++ {
if lb[d] < chosen {
lb[d] = chosen
}
}
}
if ok {
out.WriteString("YES\n")
} else {
out.WriteString("NO\n")
}
}
os.Stdout.Write(out.Bytes())
}