#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, p;
cin >> n >> k >> p;
vector<int> rows(n, 0), columns(n, 0);
vector<vector<int>> rooks(n, vector<int>(n, 0));
while (k--) {
int r, c, x;
cin >> r >> c >> x;
--r; --c;
rows[r] ^= x;
columns[c] ^= x;
rooks[r][c] = x;
}
while (p--) {
int r1, c1, r2, c2;
cin >> r1 >> c1 >> r2 >> c2;
--r1; --r2; --c1; --c2;
rows[r1] ^= rooks[r1][c1];
columns[c1] ^= rooks[r1][c1];
rooks[r2][c2] = rooks[r1][c1];
rooks[r1][c1] = 0;
rows[r2] ^= rooks[r2][c2];
columns[c2] ^= rooks[r2][c2];
int total = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (((rows[i] ^ rooks[i][j]) ^ (columns[j] ^ rooks[i][j])) > 0) ++total;
}
}
cout << total << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Runtime error |
23 ms |
65536 KB |
Execution killed with signal 9 |
7 |
Runtime error |
23 ms |
65536 KB |
Execution killed with signal 9 |
8 |
Runtime error |
43 ms |
65536 KB |
Execution killed with signal 9 |
9 |
Runtime error |
22 ms |
65536 KB |
Execution killed with signal 9 |
10 |
Runtime error |
26 ms |
65536 KB |
Execution killed with signal 9 |
11 |
Runtime error |
18 ms |
65536 KB |
Execution killed with signal 9 |
12 |
Runtime error |
16 ms |
65536 KB |
Execution killed with signal 9 |
13 |
Runtime error |
15 ms |
65536 KB |
Execution killed with signal 9 |
14 |
Runtime error |
18 ms |
65536 KB |
Execution killed with signal 9 |
15 |
Runtime error |
18 ms |
65536 KB |
Execution killed with signal 9 |
16 |
Runtime error |
17 ms |
65536 KB |
Execution killed with signal 9 |
17 |
Runtime error |
20 ms |
65536 KB |
Execution killed with signal 9 |
18 |
Runtime error |
15 ms |
65536 KB |
Execution killed with signal 9 |
19 |
Runtime error |
17 ms |
65536 KB |
Execution killed with signal 9 |
20 |
Runtime error |
15 ms |
65536 KB |
Execution killed with signal 9 |