Submission #154137

#TimeUsernameProblemLanguageResultExecution timeMemory
154137Linca_RobertTopovi (COCI15_topovi)C++14
60 / 120
2063 ms39408 KiB
#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 timeMemoryGrader output
Fetching results...