#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k, q;
cin >> n >> k >> q;
int u1[n + 1] = {0};
int u2[n + 1] = {0};
map<pair<int,int>, int> M;
for(int i = 1; i <= k; i++) {
int r, c, x;
cin >> r >> c >> x;
u1[r] ^= x;
u2[c] ^= x;
M[{r, c}] = x;
}
while(q--) {
int r1, c1, r2, c2;
cin >> r1 >> c1 >> r2 >> c2;
int value = M[{r1, c1}];
M[{r1, c1}] = 0;
u1[r1] ^= value;
u2[c1] ^= value;
u1[r2] ^= value;
u2[c2] ^= value;
M[{r2, c2}] = value;
int ans = 0;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
if((u1[i] ^ u2[j]) > 0) {
ans += 1;
}
}
}
cout << ans << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |