Submission #164099

#TimeUsernameProblemLanguageResultExecution timeMemory
164099beso123Topovi (COCI15_topovi)C++14
30 / 120
1532 ms33652 KiB
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);++i) #define repA(i,a,n) for(int i=a;i<=(n);++i) #define repD(i,a,n) for(int i=a;i>=(n);--i) #define f first #define s second #define pb push_back #define mp make_pair #define ll long long using namespace std; map<int,int> xorr,xorc; map<int,int> cntr,cntc; map<pair<int,int>,int> rook; ll ans = 0; int n,k,p; void add(int r,int c,int x){ rook[{r,c}] ^= x; ans -= n-cntc[xorr[r]]; ans -= n-cntr[xorc[c]]; if (xorr[r] != xorc[c]) ans++; cntc[xorc[c]]--; cntr[xorr[r]]--; xorr[r] ^= x; xorc[c] ^= x; cntc[xorc[c]]++; cntr[xorr[r]]++; ans += n-cntc[xorr[r]]; ans += n-cntr[xorc[c]]; if (xorr[r] != xorc[c]) ans--; } int main(){ scanf("%d%d%d",&n,&k,&p); cntr[0] = n; cntc[0] = n; rep(i,k){ int r,c,x; scanf("%d%d%d",&r,&c,&x); add(r,c,x); } while(p--){ int r1,c1,r2,c2; scanf("%d%d%d%d",&r1,&c1,&r2,&c2); int x = rook[{r1,c1}]; add(r1,c1,x); add(r2,c2,x); printf("%d\n",ans); } return 0; }

Compilation message (stderr)

topovi.cpp: In function 'int main()':
topovi.cpp:46:23: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
      printf("%d\n",ans);
                       ^
topovi.cpp:32:6: 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:37:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%d%d%d",&r,&c,&x);
      ~~~~~^~~~~~~~~~~~~~~~~~~
topovi.cpp:42:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%d%d%d%d",&r1,&c1,&r2,&c2);
      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...