| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 230565 | ParsaAlizadeh | Topovi (COCI15_topovi) | C++17 | 1286 ms | 27784 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.
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
#include <map>
using namespace std;
int n, k, q, r1, c1, r2, c2, x;
long long ans;
map<int, int> row, col, cntr, cntc;
map<pair<int, int>, int> mp;
inline void func(int r, int c, int val) {
    ans -= n - cntc[row[r]];
    ans -= n - cntr[col[c]];
    if (row[r] != col[c])
        ans++;
    cntr[row[r]]--;
    row[r] ^= val;
    cntr[row[r]]++;
    cntc[col[c]]--;
    col[c] ^= val;
    cntc[col[c]]++;
    ans += n - cntc[row[r]];
    ans += n - cntr[col[c]];
    if (row[r] != col[c])
        ans--;
}
int main() {
    scanf("%d %d %d", &n, &k, &q);
    cntr[0] = n;
    cntc[0] = n;
    for (int i = 0; i < k; i++) {
        scanf("%d %d %d", &r1, &c1, &x);
        mp[{r1, c1}] = x;
        func(r1, c1, x);
    }
    while (q--) {
        scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
        x = mp[{r1, c1}];
        mp.erase({r1, c1});
        mp[{r2, c2}] = x;
        func(r1, c1, x);
        func(r2, c2, x);
        printf("%lld\n", ans);
    }
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
