当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6392:Reverse Game

题目描述
One day, Umaru was enjoying Coke and potato chips as usual. Suddenly, an intellectual problem appeared on the television and the person who asked the problem first and correctly will get the latest《Jump》. Umaru really wants to get the 《Jump》so she told her brother the problem and begged him to help her. But her brother didn’t know how to do it, so he told you the problem and asked you for help.
There was a $N×N$ matrix and each grid is black or white. The host reversed the color of the grid or reversed the color of the whole columns. Then the problem was how many white and black connected components. (If two grids have a common edge, we think they are connected.) To increase difficulty, the grid $(i,1)$ and the grid $(i,N)$ are connected. $(1\leq i \leq N)$.
输入解释
The first line of the input contains an integer $T (1 \le T \le 15)$, denoting the number of test cases.
In each test case, the first line contains one integer N, which means the size of the matrix.
In the next $N$ lines, each line contains $N$ integers(0 or 1) means the color of each color. 1 represents black and 0 represents white.
Then the integer $Q$ represents the number of reversals that the host does. Each line of the $Q$ lines contains several numbers. If the first number is 1, the next one number $y$ is the columns of the reversal. If the first number is 2, the next two numbers $x$ and $y$ represents the position of the reversal.
$2 \leq N \leq 200$
$1 \leq Q \leq 20000$
输出解释
The output contains $Q$ lines. The $i$-th line contains two integers which represent the number of the white and black connected components after the first $i$ operations
输入样例
1
5
0 0 0 1 1 
1 1 0 0 1 
0 1 1 0 1 
1 0 0 1 0 
1 0 1 1 0 
3
2 2 5
2 3 4
1 1
输出样例
4 5
4 3
2 2
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6392

最后修改于 2020-10-25T23:30:56+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000/5000MS(Java/Others) 65536/65536K(Java/Others)