Submission #206076

#TimeUsernameProblemLanguageResultExecution timeMemory
206076ArKCaTopovi (COCI15_topovi)C++17
120 / 120
1556 ms46200 KiB
#include <bits/stdc++.h> #define ll long long #define int ll #define mod 1000000007 #define pb push_back #define pob pop_back #define f1 first #define s2 second #define N 10004 #define K 100005 #define bol (int)ceil((say-1)/2.0) #define PII pair<int,int> #define PIII pair<int,PII> #define PIIII pair<PII,PII> #define PIIIII pair<PIII,PII> #define PIIIIII pair<PIII,PIII> using namespace std; int n,k,p,r,c,a,b,x,ans; map<int,PII>row,column; map<int,PII>::iterator it; map<int,int>ro,co; map<PII,int>kale; void update(int r,int c,int mul){ ans+=mul * (n-co[row[r].f1]); ans+=mul * (n-ro[column[c].f1]); if(column[c].f1!=row[r].f1)ans-=2*mul; } int32_t main(){ // freopen("a.gir","r",stdin); // freopen("a.cik","w",stdout); scanf("%lld %lld %lld",&n,&k,&p); ro[0]+=n; co[0]+=n; for(int i=0;i<k;i++){ scanf("%lld %lld %lld",&r,&c,&x); kale[{r,c}]=x; update(r,c,-1); ro[row[r].f1]--; row[r].f1^=x; ro[row[r].f1]++; row[r].s2++; co[column[c].f1]--; column[c].f1^=x; co[column[c].f1]++; column[c].s2++; update(r,c,1); } for(int i=0;i<p;i++){ scanf("%lld %lld %lld %lld",&r,&c,&a,&b); update(r,c,-1); update(a,b,-1); co[column[c].f1]--; column[c].f1^=kale[{r,c}]; co[column[c].f1]++; co[column[b].f1]--; column[b].f1^=kale[{r,c}]; co[column[b].f1]++; ro[row[r].f1]--; row[r].f1^=kale[{r,c}]; ro[row[r].f1]++; ro[row[a].f1]--; row[a].f1^=kale[{r,c}]; ro[row[a].f1]++; update(r,c,1); update(a,b,1); kale[{a,b}]=kale[{r,c}]; printf("%lld\n", ans); } }

Compilation message (stderr)

topovi.cpp: In function 'int32_t main()':
topovi.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld %lld",&n,&k,&p);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:41:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%lld %lld %lld",&r,&c,&x);
      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:56:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%lld %lld %lld %lld",&r,&c,&a,&b);
      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...