# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
624502 | MilosMilutinovic | Topovi (COCI15_topovi) | C++14 | 1042 ms | 37560 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.
/**
* author: wxhtzdy
* created: 07.08.2022 16:59:44
**/
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k, p;
cin >> n >> k >> p;
long long ans = n * n;
map<int, int> cx;
map<int, int> cy;
cx[0] = n;
cy[0] = n;
map<int, int> xs;
map<int, int> ys;
map<pair<int, int>, int> val;
function<void(int, int, int)> Add = [&](int x, int y, int v) {
ans -= cx[ys[y]];
ans -= cy[xs[x]];
val[{x, y}] = v;
cx[xs[x]] -= 1;
cy[ys[y]] -= 1;
xs[x] ^= v;
ys[y] ^= v;
cx[xs[x]] += 1;
cy[ys[y]] += 1;
ans += cx[ys[y]];
ans += cy[xs[x]];
};
function<void(int, int, int)> Remove = [&](int x, int y, int v) {
ans -= cx[ys[y]];
ans -= cy[xs[x]];
val[{x, y}] = 0;
cx[xs[x]] -= 1;
cy[ys[y]] -= 1;
xs[x] ^= v;
ys[y] ^= v;
cx[xs[x]] += 1;
cy[ys[y]] += 1;
ans += cx[ys[y]];
ans += cy[xs[x]];
};
for (int i = 0; i < k; i++) {
int x, y, a;
cin >> x >> y >> a;
Add(x, y, a);
}
ans = 0;
for (auto& p : cx) {
ans += p.second * 1LL * cy[p.first];
}
while (p--) {
int xa, ya, xb, yb;
cin >> xa >> ya >> xb >> yb;
Add(xb, yb, val[{xa, ya}]);
Remove(xa, ya, val[{xa, ya}]);
cout << n * n - ans << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |