forked from rituburman/hacktoberfest2020
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCherryandBits.cpp
More file actions
79 lines (70 loc) · 1.21 KB
/
CherryandBits.cpp
File metadata and controls
79 lines (70 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//You can go to the question:-https://www.codechef.com/problems/CENS20A
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,m,i,j;
cin>>n>>m;
ll a[n][m] , pre[n][m];
string s[n];
for(i=0; i<n; i++)
{
cin>>s[i];
}
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
a[i][j] = s[i][j] - '0';
pre[i][j] = 0;
}
}
ll q;
cin>>q;
ll x1,y1,x2,y2;
while(q--)
{
cin>>x1>>y1>>x2>>y2;
x1--; x2--; y1--; y2--;
pre[x1][y1]++;
if(x2+1 < n && y2+1<m)
pre[x2+1][y2+1]++;
if(x2+1 < n)
pre[x2+1][y1]--;
if(y2+1 < m)
pre[x1][y2+1]--;
}
for(i=0; i<m; i++)
{
for(j=1; j<n; j++)
{
pre[j][i] = pre[j][i] + pre[j-1][i];
}
}
for(i=0; i<n; i++)
{
for(j=1; j<m; j++)
{
pre[i][j] = pre[i][j] + pre[i][j-1];
}
}
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
if(pre[i][j]%2 != 0)
{
if(a[i][j] == 1)
cout<<"0";
else
cout<<"1";
}
else
cout<<a[i][j];
}
cout<<"\n";
}
return 0;
}