For problem statement at 1000-1999/1100-1199/1100-1109/1103/problemA.txt this is a correct solution, but verifier at 1000-1999/1100-1199/1100-1109/1103/verifierA.go ends with case 5 failed: tile 401 overlaps
input: 010010111111100001010000010000001000101111110100111100001001111110011010010110011111111001001101010111000001111100101111000101011101100011000000011010101000001100110010001001001100011000100111100010011000011101101101111001001010110010100001100101010100010010011111000000010001011100010110000101100111001010110101100100001111011011001011100100000100101100101100110010001011011010110011111010000101101101110110101011010001101001001001010100100000010011110101100000101110011111010001100110000101000000011000001111101011001000010001001011001101001110100000111000110110111101000100010101100001001100
output:
1 1
1 3
3 1
1 1
3 1
3 3
2 2
1 2
2 3
3 3
1 1
1 3
1 1
3 1
1 3
3 3
1 3
2 1
1 1
3 1
3 3
1 3
3 3
1 3
3 3
1 3
1 3
3 3
1 3
3 3
1 3
3 3
2 3
1 1
1 3
3 3
3 3
3 1
1 1
1 3
1 1
1 3
1 1
1 3
1 1
1 3
3 1
1 1
3 1
3 3
3 1
3 3
3 1
1 1
3 1
1 1
3 1
3 3
1 2
2 3
1 1
1 3
1 1
1 3
1 1
1 3
1 3
3 3
3 1
3 3
1 3
1 1
1 3
3 3
3 1
1 1
3 1
3 3
1 3
3 3
3 1
3 3
3 1
3 3
3 1
3 3
3 1
3 3
1 3
3 3
3 1
3 3
1 3
1 1
1 3
2 1
1 1
3 1
3 3
1 3
2 3
3 3
1 1
3 1
1 1
3 1
1 1
1 3
3 1
3 3
3 1
3 3
3 1
1 1
3 1
3 3
2 2
1 2
2 3
3 3
1 1
3 1
1 1
1 3
3 1
1 1
1 1
1 3
3 1
3 3
3 1
1 1
1 1
3 1
1 3
3 3
1 3
1 1
1 3
3 3
1 3
3 3
1 3
3 3
1 3
2 1
3 1
1 1
3 3
3 1
3 1
1 1
3 3
3 1
1 1
3 1
1 1
3 1
3 1
3 3
1 1
3 1
3 1
3 3
1 1
3 1
3 1
1 1
3 3
1 3
3 3
3 1
1 1
3 1
3 3
1 3
3 3
3 1
3 3
1 3
3 3
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3 3
1 3
1 3
3 3
1 3
3 3
1 3
3 3
2 3
1 1
1 3
3 3
3 1
3 3
3 1
3 3
3 3
3 1
1 1
1 3
1 1
3 1
1 1
3 1
1 1
1 3
3 1
1 1
1 1
1 3
1 1
3 1
1 1
1 3
1 1
1 3
1 1
3 1
1 3
1 1
1 1
3 1
1 1
1 3
1 1
3 1
1 1
1 3
1 1
3 1
1 1
3 1
1 1
3 1
1 3
1 1
1 1
3 1
1 1
3 1
1 1
3 1
1 1
1 3
1 1
3 1
1 1
3 1
1 1
1 3
3 1
3 3
3 1
3 3
3 1
1 1
1 1
1 3
3 1
3 3
1 2
2 3
1 1
1 3
1 3
3 3
3 3
3 1
1 1
3 1
1 1
3 1
1 3
2 1
1 1
3 1
3 3
3 1
1 1
3 1
3 3
3 1
3 1
1 1
3 3
1 3
2 3
3 3
1 1
1 3
3 1
1 1
3 1
1 1
3 1
1 1
1 1
1 3
1 1
3 1
1 1
1 3
3 1
3 3
2 2
1 2
1 3
3 3
1 1
3 1
3 3
3 1
3 1
1 1
3 3
1 3
3 3
3 1
1 1
3 1
3 1
1 1
3 3
3 1
3 1
3 3
1 1
3 1
1 1
3 1
3 1
1 1
3 3
1 3
2 3
1 1
1 3
exit status 1 can you fix the verifier? package main
import (
"bufio"
"fmt"
"os"
)
type Grid struct {
a [4][4]bool
}
func (g *Grid) canPlaceVert(r, c int) bool {
if r < 0 || r > 2 || c < 0 || c > 3 {
return false
}
return !g.a[r][c] && !g.a[r+1][c]
}
func (g *Grid) canPlaceHori(r, c int) bool {
if r < 0 || r > 3 || c < 0 || c > 2 {
return false
}
return !g.a[r][c] && !g.a[r][c+1]
}
func (g *Grid) placeVert(r, c int) {
g.a[r][c] = true
g.a[r+1][c] = true
g.clearFull()
}
func (g *Grid) placeHori(r, c int) {
g.a[r][c] = true
g.a[r][c+1] = true
g.clearFull()
}
func (g *Grid) clearFull() {
fullRow := [4]bool{}
fullCol := [4]bool{}
for i := 0; i < 4; i++ {
fullRow[i] = true
for j := 0; j < 4; j++ {
if !g.a[i][j] {
fullRow[i] = false
break
}
}
}
for j := 0; j < 4; j++ {
fullCol[j] = true
for i := 0; i < 4; i++ {
if !g.a[i][j] {
fullCol[j] = false
break
}
}
}
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if fullRow[i] || fullCol[j] {
g.a[i][j] = false
}
}
}
}
func main() {
in := bufio.NewReader(os.Stdin)
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
var s string
fmt.Fscan(in, &s)
g := &Grid{}
// Priority lists that tend to create clears quickly and avoid overlaps.
// Vertical priorities: use columns 1 and 3 (0-idx: 0 and 2), rows 1 and 3 (0-idx: 0 and 2)
vCandidates := [][2]int{{0, 0}, {2, 0}, {0, 2}, {2, 2}}
// Horizontal priorities: use rows 1 and 3 (0-idx: 0 and 2), columns 1 and 3 (0-idx: 0 and 2)
hCandidates := [][2]int{{0, 0}, {0, 2}, {2, 0}, {2, 2}}
for _, ch := range s {
if ch == '0' {
placed := false
// Try priority candidates first
for _, p := range vCandidates {
r, c := p[0], p[1]
if g.canPlaceVert(r, c) {
g.placeVert(r, c)
fmt.Fprintln(out, r+1, c+1)
placed = true
break
}
}
// Fallback: try all positions
if !placed {
done := false
for r := 0; r <= 2 && !done; r++ {
for c := 0; c < 4 && !done; c++ {
if g.canPlaceVert(r, c) {
g.placeVert(r, c)
fmt.Fprintln(out, r+1, c+1)
done = true
placed = true
}
}
}
}
if !placed {
// Should not happen
fmt.Fprintln(out, 1, 1)
}
} else {
placed := false
// Try to place a horizontal that completes a row or a column first
// Check all positions to see if any completes a row/column; prefer those.
bestR, bestC := -1, -1
for r := 0; r < 4; r++ {
for c := 0; c <= 2; c++ {
if !g.canPlaceHori(r, c) {
continue
}
// simulate
g.a[r][c], g.a[r][c+1] = true, true
fullRow := true
for j := 0; j < 4; j++ {
if !g.a[r][j] {
fullRow = false
break
}
}
fullColL, fullColR := true, true
for i := 0; i < 4; i++ {
if !g.a[i][c] {
fullColL = false
}
if !g.a[i][c+1] {
fullColR = false
}
}
// revert
g.a[r][c], g.a[r][c+1] = false, false
if fullRow || fullColL || fullColR {
bestR, bestC = r, c
break
}
}
if bestR != -1 {
break
}
}
if bestR != -1 {
g.placeHori(bestR, bestC)
fmt.Fprintln(out, bestR+1, bestC+1)
placed = true
}
if !placed {
// Try priority candidates
for _, p := range hCandidates {
r, c := p[0], p[1]
if g.canPlaceHori(r, c) {
g.placeHori(r, c)
fmt.Fprintln(out, r+1, c+1)
placed = true
break
}
}
}
if !placed {
// Fallback: try all positions
done := false
for r := 0; r < 4 && !done; r++ {
for c := 0; c <= 2 && !done; c++ {
if g.canPlaceHori(r, c) {
g.placeHori(r, c)
fmt.Fprintln(out, r+1, c+1)
done = true
placed = true
}
}
}
}
if !placed {
// Should not happen
fmt.Fprintln(out, 1, 1)
}
}
}
}