CF1703E.Mirror Grid
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a square grid with n rows and n columns. Each cell contains either 0 or 1 .
In an operation, you can select a cell of the grid and flip it (from 0→1 or 1→0 ). Find the minimum number of operations you need to obtain a square that remains the same when rotated 0∘ , 90∘ , 180∘ and 270∘ .
The picture below shows an example of all rotations of a grid.
输入格式
The first line contains a single integer t ( 1≤t≤100 ) — the number of test cases.
The first line of each test case contains a single integer n ( 1≤n≤100 ) — the size of the grid.
Then n lines follow, each with n characters ai,j ( 0≤ai,j≤1 ) — the number written in each cell.
输出格式
For each test case output a single integer — the minimum number of operations needed to make the square look the same rotated 0∘ , 90∘ , 180∘ and 270∘ .
输入输出样例
输入#1
5 3 010 110 010 1 0 5 11100 11011 01011 10011 11000 5 01000 10101 01010 00010 01001 5 11001 00000 11111 10110 01111
输出#1
1 0 9 7 6
说明/提示
In the first test case, we can perform one operations to make the grid 010111010 . Now, all rotations of the square are the same.
In the second test case, all rotations of the square are already the same, so we don't need any flips.