/**
* 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 * 1LL * n - ans << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
99 ms |
5308 KB |
Output is correct |
7 |
Correct |
79 ms |
4672 KB |
Output is correct |
8 |
Correct |
66 ms |
3884 KB |
Output is correct |
9 |
Correct |
66 ms |
3984 KB |
Output is correct |
10 |
Correct |
71 ms |
4192 KB |
Output is correct |
11 |
Correct |
916 ms |
33448 KB |
Output is correct |
12 |
Correct |
957 ms |
33464 KB |
Output is correct |
13 |
Correct |
920 ms |
33424 KB |
Output is correct |
14 |
Correct |
923 ms |
33452 KB |
Output is correct |
15 |
Correct |
981 ms |
33560 KB |
Output is correct |
16 |
Correct |
985 ms |
33376 KB |
Output is correct |
17 |
Correct |
1048 ms |
33456 KB |
Output is correct |
18 |
Correct |
990 ms |
33388 KB |
Output is correct |
19 |
Correct |
917 ms |
33364 KB |
Output is correct |
20 |
Correct |
959 ms |
33420 KB |
Output is correct |