For problem statement at 1000-1999/1400-1499/1460-1469/1468/problemI.txt this is a correct solution, but verifier at 1000-1999/1400-1499/1460-1469/1468/verifierI.go ends with wrong answer on case 20
input:
4
4 4
4 3
expected:
YES
0 0
1 0
2 0
3 0
got:
YES
0 0
1 0
-1 0
2 0
exit status 1 can you fix the verifier? ```go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
var n, dx1, dy1, dx2, dy2 int64
in := bufio.NewReader(os.Stdin)
fmt.Fscan(in, &n, &dx1, &dy1, &dx2, &dy2)
D := dx1*dy2 - dx2*dy1
if D < 0 {
D = -D
}
if D != n {
fmt.Println("NO")
return
}
fmt.Println("YES")
visited := make(map[int64]bool)
type Point struct {
x, y int64
}
queue := make([]Point, 0, n)
queue = append(queue, Point{0, 0})
getHash := func(x, y int64) int64 {
A := (x*dy1 - y*dx1) % n
if A < 0 {
A += n
}
B := (x*dy2 - y*dx2) % n
if B < 0 {
B += n
}
return A*n + B
}
visited[getHash(0, 0)] = true
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
for head := 0; head < len(queue); head++ {
p := queue[head]
fmt.Fprintln(out, p.x, p.y)
dirs := []Point{{1, 0}, {-1, 0}, {0, 1}, {0, -1}}
for _, d := range dirs {
nx, ny := p.x+d.x, p.y+d.y
h := getHash(nx, ny)
if !visited[h] {
visited[h] = true
queue = append(queue, Point{nx, ny})
}
}
}
}
```