Submission #1090958

# Submission time Handle Problem Language Result Execution time Memory
1090958 2024-09-19T08:53:27 Z vjudge1 Topovi (COCI15_topovi) C++14
30 / 120
4 ms 476 KB
// [COCI2015-2016#1] TOPOVI
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int N, K, P;
  cin >> N >> K >> P;
  if (N > 1000) {  // TODO: 优化
    return 0;
  }
  unordered_map<int, int> R, C;
  using IP = array<int, 2>;
  map<IP, int> A;
  // R[r]/C[c]: 第r行/第c列的xor sum
  for (int i = 0, x, y, w; i < K and cin >> x >> y >> w; i++) {
    IP p{x, y};
    assert(!A.count(p));
    A[p] = w, R[x] ^= w, C[y] ^= w;
  }
  for (int i = 0, r1, c1, r2, c2; i < P and cin >> r1 >> c1 >> r2 >> c2; i++) {
    IP p1 = {r1, c1}, p2 = {r2, c2};
    assert(!A.count(p2));
    assert(A.count(p1));
    int w = A[p1];
    R[r1] ^= w, C[c1] ^= w, R[r2] ^= w, C[c2] ^= w;
    A.erase(p1), A[p2] = w;
    int ans = 0;
    for (int i = 1; i <= N; i++)
      for (int j = 1; j <= N; j++) ans += (R[i] ^ C[j]) > 0;
    printf("%d\n", ans);
  }
  return 0;
}
// ❓❓ 0
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 4 ms 468 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 4 ms 476 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Incorrect 0 ms 344 KB Output isn't correct
11 Incorrect 1 ms 344 KB Output isn't correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Incorrect 0 ms 348 KB Output isn't correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Incorrect 0 ms 348 KB Output isn't correct
17 Incorrect 0 ms 344 KB Output isn't correct
18 Incorrect 0 ms 468 KB Output isn't correct
19 Incorrect 0 ms 348 KB Output isn't correct
20 Incorrect 0 ms 348 KB Output isn't correct