#include<bits/stdc++.h>
using namespace std;
int N, K, P;
map<int,int> rxor, cxor, cntr, cntc;
map< pair<int,int>, int > A;
long long sol = 0;
inline void moverk( int r, int c, int x ){
sol -= N - cntc[ rxor[r] ];
sol -= N - cntr[ cxor[c] ];
if( cxor[c] != rxor[r] )
sol++;
cntr[ rxor[r] ]--;
rxor[r] ^= x;
cntr[ rxor[r] ]++;
cntc[ cxor[c] ]--;
cxor[c] ^= x;
cntc[ cxor[c] ]++;
sol += N - cntc[ rxor[r] ];
sol += N - cntr[ cxor[c] ];
if( cxor[c] != rxor[r] )
sol--;
A[make_pair( r, c )] ^= x;
}
int main(){
cin >> N >> K >> P;
cntr[0] = cntc[0] = N;
for( int i = 1; i <= K; i++ ){
int r, c, x; cin >> r >> c >> x;
r--, c--;
moverk( r, c, x );
}
for( int i = 1; i <= P; i++ ){
int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
r1--, c1--, r2--, c2--;
int x = A[ make_pair( r1, c1 ) ];
moverk( r1, c1, x );
moverk( r2, c2, x );
cout << sol << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
380 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
360 KB |
Output is correct |
6 |
Correct |
306 ms |
6000 KB |
Output is correct |
7 |
Correct |
222 ms |
5568 KB |
Output is correct |
8 |
Correct |
180 ms |
4480 KB |
Output is correct |
9 |
Correct |
176 ms |
4472 KB |
Output is correct |
10 |
Correct |
211 ms |
4804 KB |
Output is correct |
11 |
Execution timed out |
2063 ms |
38248 KB |
Time limit exceeded |
12 |
Execution timed out |
2048 ms |
36156 KB |
Time limit exceeded |
13 |
Execution timed out |
2041 ms |
37348 KB |
Time limit exceeded |
14 |
Execution timed out |
2062 ms |
39408 KB |
Time limit exceeded |
15 |
Execution timed out |
2052 ms |
38772 KB |
Time limit exceeded |
16 |
Execution timed out |
2058 ms |
38180 KB |
Time limit exceeded |
17 |
Execution timed out |
2050 ms |
38952 KB |
Time limit exceeded |
18 |
Execution timed out |
2036 ms |
37848 KB |
Time limit exceeded |
19 |
Execution timed out |
2032 ms |
37172 KB |
Time limit exceeded |
20 |
Execution timed out |
2056 ms |
37692 KB |
Time limit exceeded |