A1. Binary Table (Easy Version)
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
This is the easy version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n×mn×m. This table consists of symbols 00 and 11.
You can make such operation: select 33 different cells that belong to one 2×22×2 square and change the symbols in these cells (change 00 to 11 and 11 to 00).
Your task is to make all symbols in the table equal to 00. You are allowed to make at most 3nm3nm operations. You don't need to minimize the number of operations.
It can be proved that it is always possible.
Input
The first line contains a single integer tt (1≤t≤50001≤t≤5000) — the number of test cases. The next lines contain descriptions of test cases.
The first line of the description of each test case contains two integers nn, mm (2≤n,m≤1002≤n,m≤100).
Each of the next nn lines contains a binary string of length mm, describing the symbols of the next row of the table.
It is guaranteed that the sum of nmnm for all test cases does not exceed 2000020000.
Output
For each test case print the integer kk (0≤k≤3nm0≤k≤3nm) — the number of operations.
In the each of the next kk lines print 66 integers x1,y1,x2,y2,x3,y3x1,y1,x2,y2,x3,y3 (1≤x1,x2,x3≤n,1≤y1,y2,y3≤m1≤x1,x2,x3≤n,1≤y1,y2,y3≤m) describing the next operation. This operation will be made with three cells (x1,y1)(x1,y1), (x2,y2)(x2,y2), (x3,y3)(x3,y3). These three cells should be different. These three cells should belong into some 2×22×2 square.
Example
input
Copy
5 2 2 10 11 3 3 011 101 110 4 4 1111 0110 0110 1111 5 5 01011 11001 00010 11011 10000 2 3 011 101
output
Copy
1 1 1 2 1 2 2 2 2 1 3 1 3 2 1 2 1 3 2 3 4 1 1 1 2 2 2 1 3 1 4 2 3 3 2 4 1 4 2 3 3 4 3 4 4 4 1 2 2 1 2 2 1 4 1 5 2 5 4 1 4 2 5 1 4 4 4 5 3 4 2 1 3 2 2 2 3 1 2 2 1 2 2
Note
In the first test case, it is possible to make only one operation with cells (1,1)(1,1), (2,1)(2,1), (2,2)(2,2). After that, all symbols will be equal to 00.
In the second test case:
011 001 000
000 000 000
In the fifth test case:
010 110
000 000
之前出过类似的题目,这类题除了针对一个一个进行填补或归位没有任何好方法,突破点就在限制的次数上,3*n*m 就意味着一个点构成的2*2方阵,要想单独改变一个而不去改变其余三个,需要进行三次操作。演草可以退出四个位置的1的改变方法,然后放在图上进行分类讨论即可
- # include
- using namespace std;
- char s[110][110];
-
- int main ()
- {
-
- int t;
- cin>>t;
-
- while(t--)
- {
- int n,m;
- cin>>n>>m;
-
- int ans=0;
- for(int i=1;i<=n;i++)
- {
- for(int j=1;j<=m;j++)
- {
- cin>>s[i][j];
-
- ans+=(s[i][j]=='1');
-
- }
- }
- cout<
3< -
- for(int i=1;i<=n-1;i++)
- {
- for(int j=1;j<=m-1;j++)
- {
- if(s[i][j]=='1')
- {
- cout<" "<
" "<1<<" "<" "<1<<" "<1< -
- cout<" "<
" "<" "<1<<" "<1<<" "< -
- cout<" "<
" "<" "<1<<" "<1<<" "<1< -
- }
- }
- }
-
- for(int i=1;i<=n-1;i++)
- {
- if(s[i][m]=='1')
- {
- int j=m;
-
- cout<" "<
" "<1<<" "<1<<" "<1<<" "< -
- cout<" "<
1<<" "<" "<" "<1<<" "<1< -
- cout<" "<
" "<" "<1<<" "<1<<" "< - }
- }
-
- if(s[n][1]=='1')
- {
- int i=n,j=1;
-
- cout<" "<
" "<1<<" "<" "<1<<" "<1< -
- cout<" "<
" "<" "<1<<" "<1<<" "< -
- cout<" "<
" "<" "<1<<" "<1<<" "<1< - }
-
- for(int j=2;j<=m;j++)
- {
- if(s[n][j]=='1')
- {
- int i=n;
-
- cout<" "<
" "<1<<" "<1<<" "<" "<1< -
- cout<" "<
" "<1<<" "<" "<1<<" "<1< -
- cout<" "<
" "<1<<" "<" "<" "<1< - }
- }
- }
- return 0;
- }
-
相关阅读:
【Tomcat目录详解】关于Tomcat你还需要了解的详细内容
智能化小区管理系统(JSP+java+springmvc+mysql+MyBatis)
使用trigger VPD 限制Toad 等的访问权限
Android简易音乐重构MVVM Java版-使用DiffUtil解决recycleView整体数据刷新性能问题(二十二)
AI绘画的算法原理:从生成模型到Diffusion
(王道考研计算机网络)第四章网络层-第五节2:OSPF协议与链路状态算法
选举之Raft算法
安装Ubuntu提示:系统找不到指定的文件。
旭日图更好地呈现数据的层次结构,细致划分各项数据
初识Load Runner
-
原文地址:https://blog.csdn.net/jisuanji2606414/article/details/126213140