For problem statement at 0-999/900-999/920-929/925/problemA.txt this is a correct solution, but verifier at 0-999/900-999/920-929/925/verifierA.go ends with All tests passed. can you fix the verifier? package main
import (
"bytes"
"io"
"os"
"sort"
"strconv"
)
type FastScanner struct {
data []byte
idx int
n int
}
func NewFastScanner() *FastScanner {
data, _ := io.ReadAll(os.Stdin)
return &FastScanner{data: data, n: len(data)}
}
func (fs *FastScanner) NextInt() int {
for fs.idx < fs.n && (fs.data[fs.idx] < '0' || fs.data[fs.idx] > '9') {
fs.idx++
}
val := 0
for fs.idx < fs.n && fs.data[fs.idx] >= '0' && fs.data[fs.idx] <= '9' {
val = val*10 + int(fs.data[fs.idx]-'0')
fs.idx++
}
return val
}
func abs(x int) int {
if x < 0 {
return -x
}
return x
}
const INF = int(1 << 60)
func best(pos []int, y1, y2, vert int) int {
if len(pos) == 0 {
return INF
}
a, b := y1, y2
if a > b {
a, b = b, a
}
ans := INF
i := sort.SearchInts(pos, a)
if i < len(pos) {
p := pos[i]
cost := abs(y1-p) + abs(y2-p) + vert
if cost < ans {
ans = cost
}
}
if i > 0 {
p := pos[i-1]
cost := abs(y1-p) + abs(y2-p) + vert
if cost < ans {
ans = cost
}
}
return ans
}
func main() {
fs := NewFastScanner()
_ = fs.NextInt()
_ = fs.NextInt()
cl := fs.NextInt()
ce := fs.NextInt()
v := fs.NextInt()
stairs := make([]int, cl)
for i := 0; i < cl; i++ {
stairs[i] = fs.NextInt()
}
elevators := make([]int, ce)
for i := 0; i < ce; i++ {
elevators[i] = fs.NextInt()
}
q := fs.NextInt()
var out bytes.Buffer
for i := 0; i < q; i++ {
x1 := fs.NextInt()
y1 := fs.NextInt()
x2 := fs.NextInt()
y2 := fs.NextInt()
var ans int
if x1 == x2 {
ans = abs(y1 - y2)
} else {
df := abs(x1 - x2)
ans = INF
s := best(stairs, y1, y2, df)
if s < ans {
ans = s
}
elevTime := (df + v - 1) / v
e := best(elevators, y1, y2, elevTime)
if e < ans {
ans = e
}
}
out.WriteString(strconv.Itoa(ans))
out.WriteByte('\n')
}
os.Stdout.Write(out.Bytes())
}