#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
map <int, int> row;
map <int, int> col;
map <int, int> crow;
map <int, int> ccol;
map <pair <int, int>, int> pw;
ll tr;
void uradi(int i, int j, int p){
crow[row[i]]--;
tr -= ccol[row[i]];
row[i] ^= p;
tr += ccol[row[i]];
crow[row[i]]++;
ccol[col[j]]--;
tr -= crow[col[j]];
col[j] ^= p;
tr += crow[col[j]];
ccol[col[j]]++;
pw[{i, j}] = p;
}
int main(){
ios_base::sync_with_stdio(false), cin.tie(0);
cout.precision(10);
cout << fixed;
ll n;
int k, p;
cin >> n >> k >> p;
ccol[0] = crow[0] = n;
tr = n*n;
while(k--){
int i, j, pww;
cin >> i >> j >> pww;
uradi(i, j, pww);
}
while(p--){
int i, j;
cin >> i >> j;
int pww = pw[{i, j}];
uradi(i, j, pww);
pw[{i, j}] = 0;
cin >> i >> j;
uradi(i, j, pww);
cout << n*n - tr << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
114 ms |
5936 KB |
Output is correct |
7 |
Correct |
117 ms |
5308 KB |
Output is correct |
8 |
Correct |
91 ms |
4384 KB |
Output is correct |
9 |
Correct |
78 ms |
4496 KB |
Output is correct |
10 |
Correct |
84 ms |
4736 KB |
Output is correct |
11 |
Correct |
1120 ms |
39424 KB |
Output is correct |
12 |
Correct |
1081 ms |
39368 KB |
Output is correct |
13 |
Correct |
1112 ms |
39412 KB |
Output is correct |
14 |
Correct |
1125 ms |
39456 KB |
Output is correct |
15 |
Correct |
1135 ms |
39368 KB |
Output is correct |
16 |
Correct |
1081 ms |
39404 KB |
Output is correct |
17 |
Correct |
1072 ms |
39376 KB |
Output is correct |
18 |
Correct |
1104 ms |
39516 KB |
Output is correct |
19 |
Correct |
1070 ms |
39340 KB |
Output is correct |
20 |
Correct |
1081 ms |
39456 KB |
Output is correct |