# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100760 | dalgerok | Topovi (COCI15_topovi) | C++17 | 1517 ms | 39672 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;
int n, k, p;
map < int, int > a, b, aa, bb;
map < pair < int, int >, int > q;
long long ans;
inline void upd(int x, int y, int z){
ans -= (n - aa[a[x]]);
ans -= (n - bb[b[y]]);
aa[b[y]] -= 1;
bb[a[x]] -= 1;
a[x] ^= z;
b[y] ^= z;
aa[b[y]] += 1;
bb[a[x]] += 1;
ans += (n - aa[a[x]]);
ans += (n - bb[b[y]]);
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> k >> p;
aa[0] = bb[0] = n;
for(int i = 1; i <= k; i++){
int x, y, z;
cin >> x >> y >> z;
q[make_pair(x, y)] = z;
upd(x, y, z);
}
while(p--){
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
int z = q[make_pair(x1, y1)];
upd(x1, y1, z);
upd(x2, y2, z);
q[make_pair(x2, y2)] = q[make_pair(x1, y1)];
cout << ans << "\n";
}
}
/**
2 2 2
1 1 1
2 2 1
2 2 2 1
1 1 1 2
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |