| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 95225 | zeyad49 | Topovi (COCI15_topovi) | C++17 | 1617 ms | 39820 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 <cstdio>
#include <iostream>
#include <map>
using namespace std;
map<int,int> rows,cols,cntRows,cntCols;
map <pair<int, int>, int> power;
 long long ans;
    int n;
 void update(int r,int c,int x) {
    // subtract all cols with xor !=original xor of row r
    int original;
    original=rows[r];
    int y=n-cntCols[original];
    ans-=y;
    // add all cols with xor != new xor of row r
    int newXor=original^x;
   rows[r]=newXor;
    int z=cols[c];
    cntCols[z^x]++;
    cntCols[z]--;
    y=n-cntCols[newXor];
    ans+=y;
    cntRows[original]--;
    // subtract all rows with xor!=original xor of column c
    original=z;
    y=n-1-cntRows[original];
    ans-=y;
    newXor=original^x;
    cols[c]=newXor;
    //add all rows with xor!=new xor
    y=n-1-cntRows[newXor];
    ans+=y;
    z=rows[r];
    cntRows[z]++;
     power[make_pair(r, c)] ^= x;
}
int main() {
    cin>>n;
    int k,p;
    cin>>k>>p;
    int r,c,x;
    cntRows[0]=n;
    cntCols[0]=n;
    while(k--){
        cin>>r>>c>>x;
        r--;
        c--;
        update(r,c, x);
    }
    while(p-->0) {
        int r1,c1,r2,c2;
        cin>>r1>>c1>>r2>>c2;
        r1--;
        c1--;
        r2--;
        c2--;
        int x=power[make_pair(r1, c1)];
        update(r1, c1, x);
        update(r2,c2,x);
       cout<<ans<<'\n';
    }
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
