# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
113316 | IVIosab | Topovi (COCI15_topovi) | C++17 | 1737 ms | 46080 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>
using namespace std;
#define ll long long
#define f first
#define s second
ll n,k,p;
ll ans=0;
map<pair<int,int>,long long> mpr;
map<int,long long> rows,cols,cntrows,cntcols;
void update(int r,int c,int x){
ans-=(n-cntrows[cols[c]]);
ans-=(n-cntcols[rows[r]]);
if(rows[r]==cols[c]){
ans++;
}
cntrows[rows[r]]--;
rows[r]^=x;
cntrows[rows[r]]++;
cntcols[cols[c]]--;
cols[c]^=x;
cntcols[cols[c]]++;
ans+=(n-cntrows[cols[c]]);
ans+=(n-cntcols[rows[r]]);
if(rows[r]==cols[c]){
ans--;
}
}
int main() {
//freopen("sample-8.in", "r", stdin);
//freopen("output8.txt", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>k>>p;
cntcols[0]=cntrows[0]=n;
for(int i=0;i<k;i++){
int a,b,x;
cin>>a>>b>>x;
mpr[{a,b}]=x;
update(a,b,x);
}
for(int i=0;i<p;i++){
int a,b,c,d;
cin>>a>>b>>c>>d;
long long x=mpr[{a,b}];
update(a,b,x);
update(c,d,x);
mpr[{c,d}]=x;
cout<<ans<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |