For problem statement at 1000-1999/1400-1499/1470-1479/1472/problemF.txt this is a correct solution, but verifier at 1000-1999/1400-1499/1470-1479/1472/verifierF.go ends with Test 1 failed: expected "YES" got "NO"
Input:
1
1 7
1 1
2 6
2 7
1 4
2 8
2 9
1 4
exit status 1 can you fix the verifier? package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
)
type Cell struct {
r, c int
}
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanWords)
buf := make([]byte, 0, 64*1024)
scanner.Buffer(buf, 1024*1024)
var t int
if scanner.Scan() {
t, _ = strconv.Atoi(scanner.Text())
}
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
for tc := 0; tc < t; tc++ {
scanner.Scan()
scanner.Scan()
m, _ := strconv.Atoi(scanner.Text())
cells := make([]Cell, m)
for i := 0; i < m; i++ {
scanner.Scan()
cells[i].r, _ = strconv.Atoi(scanner.Text())
scanner.Scan()
cells[i].c, _ = strconv.Atoi(scanner.Text())
}
sort.Slice(cells, func(i, j int) bool {
if cells[i].c != cells[j].c {
return cells[i].c < cells[j].c
}
return cells[i].r < cells[j].r
})
possible := true
has_pending := false
prev_c := 0
prev_r := 0
for i := 0; i < m; {
if i+1 < m && cells[i].c == cells[i+1].c {
if has_pending {
possible = false
break
}
i += 2
} else {
c := cells[i].c
r := cells[i].r
if has_pending {
diff_c := c - prev_c
expected_mod := 0
if r == prev_r {
expected_mod = 1
}
if diff_c%2 != expected_mod {
possible = false
break
}
has_pending = false
} else {
has_pending = true
prev_c = c
prev_r = r
}
i += 1
}
}
if has_pending {
possible = false
}
if possible {
fmt.Fprintln(out, "YES")
} else {
fmt.Fprintln(out, "NO")
}
}
}