# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
743796 | JellyTheOctopus | Topovi (COCI15_topovi) | C++17 | 1536 ms | 39496 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int N, K, P;
long long ans = 0;
map<int, int> rowCnt, colCnt;
map<int, int> rowXOR, colXOR;
map<pair<int, int>, int> rook;
void move(int r, int c, int val) {
ans -= (N-colCnt[rowXOR[r]]);
ans -= (N-rowCnt[colXOR[c]]);
if (rowXOR[r] != colXOR[c]) {
ans++;
}
rowCnt[rowXOR[r]]--;
rowXOR[r] ^= val;
rowCnt[rowXOR[r]]++;
colCnt[colXOR[c]]--;
colXOR[c] ^= val;
colCnt[colXOR[c]]++;
ans += (N-colCnt[rowXOR[r]]);
ans += (N-rowCnt[colXOR[c]]);
if (rowXOR[r] != colXOR[c]){
ans--;
}
rook[{r, c}] ^= val;
}
int main() {
cin >> N >> K >> P;
rowCnt[0] = N;
colCnt[0] = N;
while (K--) {
int r, c, val;
cin >> r >> c >> val;
r--;
c--;
move(r, c, val);
}
while (P--) {
int r1, c1, r2, c2;
cin >> r1 >> c1 >> r2 >> c2;
r1--; c1--; r2--; c2--;
int rookVal = rook[{r1, c1}];
move(r1, c1, rookVal);
move(r2, c2, rookVal);
cout << ans << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |