Submission #624489

# Submission time Handle Problem Language Result Execution time Memory
624489 2022-08-08T10:46:09 Z MilosMilutinovic Topovi (COCI15_topovi) C++14
30 / 120
2000 ms 21240 KB
/**
 *    author:  wxhtzdy
 *    created: 07.08.2022 16:59:44
**/
#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;
  long long ans = n * n;
  map<int, int> cx;
  map<int, int> cy;
  cx[0] = n;   
  cy[0] = n;
  map<int, int> xs;
  map<int, int> ys;
  map<pair<int, int>, int> val;
  function<void(int, int, int)> Add = [&](int x, int y, int v) {
    ans -= cx[ys[y]];
    val[{x, y}] = v;
    cx[xs[x]] -= 1;
    cy[ys[y]] -= 1;
    xs[x] ^= v;
    ys[y] ^= v;
    cx[xs[x]] += 1;
    cy[ys[y]] += 1;
    ans += cx[ys[y]];
  };
  function<void(int, int, int)> Remove = [&](int x, int y, int v) {
    ans -= cx[ys[y]];
    val[{x, y}] = 0;
    cx[xs[x]] -= 1;
    cy[ys[y]] -= 1;
    xs[x] ^= v;
    ys[y] ^= v;
    cx[xs[x]] += 1;
    cy[ys[y]] += 1;
    ans += cx[ys[y]];
  };
  for (int i = 0; i < k; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    Add(x, y, a);
  }
  while (p--) {
    int xa, ya, xb, yb;
    cin >> xa >> ya >> xb >> yb;
    Add(xb, yb, val[{xa, ya}]);
    Remove(xa, ya, val[{xa, ya}]);
    ans = 0;
    for (auto& p : cx) {
      ans += p.second * 1LL * cy[p.first];
    }
    cout << n * n - ans << '\n';
  }                                                                  
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Incorrect 223 ms 6060 KB Output isn't correct
7 Incorrect 208 ms 5320 KB Output isn't correct
8 Incorrect 140 ms 4388 KB Output isn't correct
9 Incorrect 138 ms 4556 KB Output isn't correct
10 Incorrect 153 ms 4772 KB Output isn't correct
11 Execution timed out 2073 ms 21128 KB Time limit exceeded
12 Execution timed out 2081 ms 21104 KB Time limit exceeded
13 Execution timed out 2084 ms 21240 KB Time limit exceeded
14 Execution timed out 2082 ms 21172 KB Time limit exceeded
15 Execution timed out 2065 ms 21008 KB Time limit exceeded
16 Execution timed out 2081 ms 21080 KB Time limit exceeded
17 Execution timed out 2086 ms 21064 KB Time limit exceeded
18 Execution timed out 2093 ms 21164 KB Time limit exceeded
19 Execution timed out 2065 ms 21176 KB Time limit exceeded
20 Execution timed out 2081 ms 20884 KB Time limit exceeded