/**
* 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 |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
6 |
Incorrect |
107 ms |
5856 KB |
Output isn't correct |
7 |
Incorrect |
84 ms |
5316 KB |
Output isn't correct |
8 |
Incorrect |
66 ms |
4356 KB |
Output isn't correct |
9 |
Incorrect |
76 ms |
4536 KB |
Output isn't correct |
10 |
Incorrect |
79 ms |
4712 KB |
Output isn't correct |
11 |
Incorrect |
1033 ms |
37532 KB |
Output isn't correct |
12 |
Incorrect |
1042 ms |
37504 KB |
Output isn't correct |
13 |
Incorrect |
971 ms |
37512 KB |
Output isn't correct |
14 |
Incorrect |
1031 ms |
37480 KB |
Output isn't correct |
15 |
Incorrect |
1012 ms |
37528 KB |
Output isn't correct |
16 |
Incorrect |
995 ms |
37480 KB |
Output isn't correct |
17 |
Incorrect |
972 ms |
37500 KB |
Output isn't correct |
18 |
Incorrect |
959 ms |
37540 KB |
Output isn't correct |
19 |
Incorrect |
1000 ms |
37444 KB |
Output isn't correct |
20 |
Incorrect |
910 ms |
37560 KB |
Output isn't correct |