AcWing 5396. 棋盘
原题链接
简单
作者:
RanPg
,
2024-02-28 16:02:09
,
所有人可见
,
阅读 30
C++ 代码
#include<bits/stdc++.h>
using namespace std;
const int N = 2010;
int s[N][N];
int n, m;
void op(int x1, int y1, int x2, int y2)
{
s[x1][y1] += 1;
s[x1][y2 + 1] -= 1;
s[x2 + 1][y1] -= 1;
s[x2 + 1][y2 + 1] += 1;
}
int main()
{
cin >> n >> m;
while(m --)
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
op(x1, y1, x2, y2);
}
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= n; j ++)
s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
for(int i = 1; i <= n; i ++)
{
for(int j = 1; j <= n; j ++)
cout << s[i][j] % 2;
cout << endl;
}
return 0;
}