# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
206076 | ArKCa | Topovi (COCI15_topovi) | C++17 | 1556 ms | 46200 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |