# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
154276 | SeekingOblivion | Topovi (COCI15_topovi) | C++14 | 1484 ms | 35956 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<fstream>
#include<map>
#include<cstdio>
//#define fin cin
//#define fout cout
using namespace std;
//ifstream fin("date.in");
//ofstream fout("date.out");
int i,j,n,k,p,s;
long long sol;
map<int,int> xori,xorj,fi,fj;
map<pair<int,int>,int> r;
void solve(int i,int j,int p)
{
sol-=n-fj[xori[i]];
sol-=n-fi[xorj[j]];
fi[xori[i]]--;xori[i]^=p;fi[xori[i]]++;
fj[xorj[j]]--;xorj[j]^=p;fj[xorj[j]]++;
sol+=n-fj[xori[i]];
sol+=n-fi[xorj[j]];
r[make_pair(i,j)]^=p;
}
int main()
{
scanf("%d %d %d",&n,&k,&p);
fi[0]=fj[0]=n;
for(;k--;)
{
scanf("%d %d %d",&i,&j,&s);
solve(i,j,s);
}
for(;p--;)
{
scanf("%d %d",&i,&j);
s=r[make_pair(i,j)];
solve(i,j,s);
scanf("%d %d",&i,&j);
solve(i,j,s);
printf("%lld\n",sol);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |