# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
154137 | Linca_Robert | Topovi (COCI15_topovi) | C++14 | 2063 ms | 39408 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |