| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 743796 | JellyTheOctopus | Topovi (COCI15_topovi) | C++17 | 1536 ms | 39496 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... | ||||
