#include <iostream>
#include <vector>
#include <map>
using namespace std;
int N, K, P, attacked;
vector<int> rowXOR, colXOR, powers;
map<pair<int, int>, int> rooks;
map<int, int> valRows, valCols;
void init() {
attacked = 0;
rowXOR.assign(N, 0);
colXOR.assign(N, 0);
valRows[0] = N;
valCols[0] = N;
}
void include(int r, int c, int p) {
attacked -= (N - valRows[colXOR[c]]);
attacked -= (N - valCols[rowXOR[r]]);
valRows[rowXOR[r]]--;
valCols[colXOR[c]]--;
rooks[{r, c}] = p;
rowXOR[r] ^= p;
colXOR[c] ^= p;
valRows[rowXOR[r]]++;
valCols[colXOR[c]]++;
attacked += (N - valRows[colXOR[c]]);
attacked += (N - valCols[rowXOR[r]]);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int r, c, p, r2, c2;
cin >> N >> K >> P;
init();
for (int i = 0; i < K; i++) {
cin >> r >> c >> p;
include(r-1, c-1, p);
//cout << attacked << '\n';
}
for (int i = 0; i < P; i++) {
cin >> r >> c >> r2 >> c2;
p = rooks[{r-1, c-1}];
include(r-1, c-1, p);
include(r2-1, c2-1, p);
cout << attacked << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Incorrect |
55 ms |
16748 KB |
Output isn't correct |
7 |
Incorrect |
41 ms |
11244 KB |
Output isn't correct |
8 |
Incorrect |
37 ms |
14828 KB |
Output isn't correct |
9 |
Incorrect |
37 ms |
14956 KB |
Output isn't correct |
10 |
Incorrect |
40 ms |
15596 KB |
Output isn't correct |
11 |
Runtime error |
51 ms |
65540 KB |
Execution killed with signal 9 |
12 |
Runtime error |
53 ms |
65540 KB |
Execution killed with signal 9 |
13 |
Runtime error |
48 ms |
65540 KB |
Execution killed with signal 9 |
14 |
Runtime error |
48 ms |
65540 KB |
Execution killed with signal 9 |
15 |
Runtime error |
47 ms |
65536 KB |
Execution killed with signal 9 |
16 |
Runtime error |
50 ms |
65540 KB |
Execution killed with signal 9 |
17 |
Runtime error |
48 ms |
65540 KB |
Execution killed with signal 9 |
18 |
Runtime error |
50 ms |
65540 KB |
Execution killed with signal 9 |
19 |
Runtime error |
50 ms |
65536 KB |
Execution killed with signal 9 |
20 |
Runtime error |
48 ms |
65540 KB |
Execution killed with signal 9 |