For problem statement at 1000-1999/1200-1299/1200-1209/1202/problemC.txt this is a correct solution, but verifier at 1000-1999/1200-1299/1200-1209/1202/verifierC.go ends with All 100 tests passed can you fix the verifier? package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
buf := make([]byte, 1024*1024)
scanner.Buffer(buf, 1024*1024)
scanner.Split(bufio.ScanWords)
if !scanner.Scan() {
return
}
t, _ := strconv.Atoi(scanner.Text())
for i := 0; i < t; i++ {
if !scanner.Scan() {
break
}
s := scanner.Text()
x, y := 0, 0
minX, maxX := 0, 0
minY, maxY := 0, 0
for j := 0; j < len(s); j++ {
c := s[j]
if c == 'W' {
y++
} else if c == 'S' {
y--
} else if c == 'A' {
x--
} else if c == 'D' {
x++
}
if x < minX {
minX = x
}
if x > maxX {
maxX = x
}
if y < minY {
minY = y
}
if y > maxY {
maxY = y
}
}
firstMaxX, lastMaxX := -1, -1
firstMinX, lastMinX := -1, -1
firstMaxY, lastMaxY := -1, -1
firstMinY, lastMinY := -1, -1
x, y = 0, 0
if x == minX {
firstMinX = 0
lastMinX = 0
}
if x == maxX {
firstMaxX = 0
lastMaxX = 0
}
if y == minY {
firstMinY = 0
lastMinY = 0
}
if y == maxY {
firstMaxY = 0
lastMaxY = 0
}
for j := 0; j < len(s); j++ {
c := s[j]
if c == 'W' {
y++
} else if c == 'S' {
y--
} else if c == 'A' {
x--
} else if c == 'D' {
x++
}
pos := j + 1
if x == minX {
if firstMinX == -1 {
firstMinX = pos
}
lastMinX = pos
}
if x == maxX {
if firstMaxX == -1 {
firstMaxX = pos
}
lastMaxX = pos
}
if y == minY {
if firstMinY == -1 {
firstMinY = pos
}
lastMinY = pos
}
if y == maxY {
if firstMaxY == -1 {
firstMaxY = pos
}
lastMaxY = pos
}
}
xExt := int64(maxX - minX + 1)
yExt := int64(maxY - minY + 1)
xCanReduce := false
if xExt > 2 && (lastMaxX < firstMinX || lastMinX < firstMaxX) {
xCanReduce = true
}
yCanReduce := false
if yExt > 2 && (lastMaxY < firstMinY || lastMinY < firstMaxY) {
yCanReduce = true
}
ans := xExt * yExt
if xCanReduce {
cand := (xExt - 1) * yExt
if cand < ans {
ans = cand
}
}
if yCanReduce {
cand := xExt * (yExt - 1)
if cand < ans {
ans = cand
}
}
fmt.Println(ans)
}
}