| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 98651 | duy_tran | Topovi (COCI15_topovi) | C++14 | 1799 ms | 33668 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;
int k,p;
long long n,safe;
map<pair<int,int>,int> val;
map<int,int> rowv,colv,nrow,ncol;
void Move(int r,int c)
{
    int x=val[{r,c}];
    int vr=rowv[r];
    int vc=colv[c];
    int nr=nrow[vc];
    int nc=ncol[vr];
    safe-=nc;
    safe-=nr;
    if(ncol[vc])--ncol[vc];
    if(nrow[vr])--nrow[vr];
    if(vr==vc)++safe;
    vr^=x;
    vc^=x;
    rowv[r]=vr;
    colv[c]=vc;
    ++ncol[vc];
    ++nrow[vr];
    safe+=nrow[vc];
    safe+=ncol[vr];
    if(vc==vr && safe)--safe;
}
int main()
{
    cin>>n>>k>>p;
    safe=n*n;
    ncol[0]=n;
    nrow[0]=n;
    for(int i=1;i<=k;++i)
    {
        int r,c,x;
        cin>>r>>c>>x;
        val[{r,c}]=x;
        Move(r,c);
    }
    for(int i=1;i<=p;++i)
    {
        int r1,c1,r2,c2;
        cin>>r1>>c1>>r2>>c2;
        Move(r1,c1);
        val[{r2,c2}]=val[{r1,c1}];
        val[{r1,c1}]=0;
        Move(r2,c2);
        cout<<n*n-safe<<'\n';
    }
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
