| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1015989 | May27_th | Topovi (COCI15_topovi) | C++17 | 749 ms | 27272 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;
#define i64 long long
#define i128 __int128
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
map<int, int> sumR, sumC, cntR, cntC;
map<pair<int, int>, int> rock;
void Solve(void) {
  int N, K, P; cin >> N >> K >> P;
  i64 ans = 0;
  cntR[0] = cntC[0] = N;
  auto Move = [&] (int r, int c) {
    ans = ans - (N - cntC[sumR[r]]);
    ans = ans - (N - cntR[sumC[c]]);
    if (sumR[r] != sumC[c]) ans ++;
    cntR[sumR[r]] --;
    cntC[sumC[c]] --;
    sumR[r] ^= rock[mp(r, c)];
    sumC[c] ^= rock[mp(r, c)];
    cntR[sumR[r]] ++;
    cntC[sumC[c]] ++;
    ans = ans + (N - cntC[sumR[r]]);
    ans = ans + (N - cntR[sumC[c]]);
    if (sumR[r] != sumC[c]) ans --;
  };
  
  for (int i = 1; i <= K; i ++) {
    int r, c, x; cin >> r >> c >> x;
    rock[mp(r, c)] = x;
    Move(r, c);
  }
  while (P --) {
    int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
    Move(r1, c1);
    rock[mp(r2, c2)] = rock[mp(r1, c1)];
    rock.erase(mp(r1, c1));
    Move(r2, c2);
    cout << ans << "\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(10);
  int Tests = 1; // cin >> Tests;
  while (Tests --) {
    Solve();
  }
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
