For problem statement at 1000-1999/1100-1199/1180-1189/1185/problemE.txt this is a correct solution, but verifier at 1000-1999/1100-1199/1180-1189/1185/verifierE.go ends with case 13 failed
expected:
YES
3
1 2 1 2
1 1 1 1
1 2 1 2
got:
YES
3
1 1 1 1
1 1 1 1
1 2 1 2
exit status 1 can you fix the verifier? ```go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var t int
fmt.Fscan(reader, &t)
for tc := 0; tc < t; tc++ {
var n, m int
fmt.Fscan(reader, &n, &m)
grid := make([]string, n)
for i := 0; i < n; i++ {
fmt.Fscan(reader, &grid[i])
}
minR := make([]int, 26)
maxR := make([]int, 26)
minC := make([]int, 26)
maxC := make([]int, 26)
has := make([]bool, 26)
for i := 0; i < 26; i++ {
minR[i] = n
maxR[i] = -1
minC[i] = m
maxC[i] = -1
}
maxIdx := -1
for i := 0; i < n; i++ {
row := grid[i]
for j := 0; j < m; j++ {
ch := row[j]
if ch == '.' {
continue
}
idx := int(ch - 'a')
has[idx] = true
if idx > maxIdx {
maxIdx = idx
}
if i < minR[idx] {
minR[idx] = i
}
if i > maxR[idx] {
maxR[idx] = i
}
if j < minC[idx] {
minC[idx] = j
}
if j > maxC[idx] {
maxC[idx] = j
}
}
}
if maxIdx == -1 {
fmt.Fprintln(writer, "YES")
fmt.Fprintln(writer, 0)
continue
}
r1 := make([]int, 26)
c1 := make([]int, 26)
r2 := make([]int, 26)
c2 := make([]int, 26)
possible := true
for idx := maxIdx; idx >= 0; idx-- {
if !has[idx] {
r1[idx] = r1[idx+1]
c1[idx] = c1[idx+1]
r2[idx] = r2[idx+1]
c2[idx] = c2[idx+1]
continue
}
if minR[idx] != maxR[idx] && minC[idx] != maxC[idx] {
possible = false
break
}
r1[idx] = minR[idx]
c1[idx] = minC[idx]
r2[idx] = maxR[idx]
c2[idx] = maxC[idx]
if minR[idx] == maxR[idx] {
r := minR[idx]
for c := minC[idx]; c <= maxC[idx]; c++ {
if grid[r][c] < byte('a'+idx) {
possible = false
break
}
}
} else {
c := minC[idx]
for r := minR[idx]; r <= maxR[idx]; r++ {
if grid[r][c] < byte('a'+idx) {
possible = false
break
}
}
}
if !possible {
break
}
}
if !possible {
fmt.Fprintln(writer, "NO")
} else {
fmt.Fprintln(writer, "YES")
fmt.Fprintln(writer, maxIdx+1)
for i := 0; i <= maxIdx; i++ {
fmt.Fprintf(writer, "%d %d %d %d\n", r1[i]+1, c1[i]+1, r2[i]+1, c2[i]+1)
}
}
}
}
```