# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
98651 |
2019-02-25T02:37:08 Z |
duy_tran |
Topovi (COCI15_topovi) |
C++14 |
|
1799 ms |
33668 KB |
#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 |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
214 ms |
5452 KB |
Output is correct |
7 |
Correct |
154 ms |
4724 KB |
Output is correct |
8 |
Correct |
118 ms |
3960 KB |
Output is correct |
9 |
Correct |
123 ms |
3960 KB |
Output is correct |
10 |
Correct |
138 ms |
4204 KB |
Output is correct |
11 |
Correct |
1773 ms |
33668 KB |
Output is correct |
12 |
Correct |
1799 ms |
33532 KB |
Output is correct |
13 |
Correct |
1685 ms |
33468 KB |
Output is correct |
14 |
Correct |
1704 ms |
33500 KB |
Output is correct |
15 |
Correct |
1634 ms |
33596 KB |
Output is correct |
16 |
Correct |
1639 ms |
33620 KB |
Output is correct |
17 |
Correct |
1714 ms |
33588 KB |
Output is correct |
18 |
Correct |
1650 ms |
33656 KB |
Output is correct |
19 |
Correct |
1684 ms |
33632 KB |
Output is correct |
20 |
Correct |
1614 ms |
33544 KB |
Output is correct |