← Home
For problem statement at 0-999/0-99/0-9/7/problemA.txt this is a correct solution, but verifier at 0-999/0-99/0-9/7/verifierA.go ends with Test 1 failed: expected 0 got 100

exit status 1 can you fix the verifier? package main

import (
	"bufio"
	"fmt"
	"math/bits"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	board := make([]string, 8)
	for i := 0; i < 8; i++ {
		fmt.Fscan(in, &board[i])
	}

	ans := 100
	for r := 0; r < 1<<8; r++ {
		for c := 0; c < 1<<8; c++ {
			ok := true
			for i := 0; i < 8 && ok; i++ {
				for j := 0; j < 8; j++ {
					black := ((r>>i)&1) == 1 || ((c>>j)&1) == 1
					if black != (board[i][j] == 'B') {
						ok = false
						break
					}
				}
			}
			if ok {
				cnt := bits.OnesCount(uint(r)) + bits.OnesCount(uint(c))
				if cnt < ans {
					ans = cnt
				}
			}
		}
	}

	fmt.Println(ans)
}