Submission #154138

#TimeUsernameProblemLanguageResultExecution timeMemory
154138Linca_RobertTopovi (COCI15_topovi)C++14
120 / 120
1618 ms34492 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(){ scanf( "%d%d%d", &N, &K, &P ); cntr[0] = cntc[0] = N; for( int i = 1; i <= K; i++ ){ int r, c, x; scanf( "%d%d%d", &r, &c, &x ); r--, c--; moverk( r, c, x ); } for( int i = 1; i <= P; i++ ){ int r1, c1, r2, c2; scanf( "%d%d%d%d", &r1, &c1, &r2, &c2 ); r1--, c1--, r2--, c2--; int x = A[ make_pair( r1, c1 ) ]; moverk( r1, c1, x ); moverk( r2, c2, x ); printf( "%lld\n", sol ); } return 0; }

Compilation message (stderr)

topovi.cpp: In function 'int main()':
topovi.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf( "%d%d%d", &N, &K, &P );
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:34:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int r, c, x; scanf( "%d%d%d", &r, &c, &x );
                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:40:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int r1, c1, r2, c2; scanf( "%d%d%d%d", &r1, &c1, &r2, &c2 );
                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...