Submission #206076

# Submission time Handle Problem Language Result Execution time Memory
206076 2020-03-02T07:33:29 Z ArKCa Topovi (COCI15_topovi) C++17
120 / 120
1556 ms 46200 KB
#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

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 time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 172 ms 7032 KB Output is correct
7 Correct 134 ms 6264 KB Output is correct
8 Correct 115 ms 5236 KB Output is correct
9 Correct 115 ms 5240 KB Output is correct
10 Correct 124 ms 5496 KB Output is correct
11 Correct 1522 ms 46044 KB Output is correct
12 Correct 1527 ms 45872 KB Output is correct
13 Correct 1529 ms 46068 KB Output is correct
14 Correct 1510 ms 45944 KB Output is correct
15 Correct 1556 ms 45816 KB Output is correct
16 Correct 1527 ms 46072 KB Output is correct
17 Correct 1513 ms 46084 KB Output is correct
18 Correct 1522 ms 45944 KB Output is correct
19 Correct 1539 ms 46200 KB Output is correct
20 Correct 1499 ms 46072 KB Output is correct