← Home
For problem statement at 1000-1999/1300-1399/1360-1369/1366/problemC.txt this is a correct solution, but verifier at 1000-1999/1300-1399/1360-1369/1366/verifierC.go ends with All 100 tests passed can you fix the verifier? package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var t int
	if _, err := fmt.Fscan(in, &t); err != nil {
		return
	}
	for ; t > 0; t-- {
		var n, m int
		fmt.Fscan(in, &n, &m)
		total := n + m
		cnt0 := make([]int, total+3)
		cnt1 := make([]int, total+3)
		for i := 1; i <= n; i++ {
			for j := 1; j <= m; j++ {
				var x int
				fmt.Fscan(in, &x)
				s := i + j
				if x == 0 {
					cnt0[s]++
				} else {
					cnt1[s]++
				}
			}
		}
		ans := 0
		limit := (total + 1) / 2
		for s := 2; s <= limit; s++ {
			s2 := total + 2 - s
			zeros := cnt0[s] + cnt0[s2]
			ones := cnt1[s] + cnt1[s2]
			if zeros < ones {
				ans += zeros
			} else {
				ans += ones
			}
		}
		fmt.Fprintln(out, ans)
	}
}