# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153933 | Ruxandra985 | Topovi (COCI15_topovi) | C++14 | 1750 ms | 33400 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 <set>
#include <map>
#include <algorithm>
using namespace std;
map <int,int> line,col,fl,fc;
map <pair <int,int> , int > mp;
long long sol = 0;
int n;
void add (int r , int c , int x){
sol = sol - (n - fc[line[r]]);
sol = sol - (n - fl[col[c]]);
if (line[r] == col[c])
sol++;
fl[line[r]]--;
fc[col[c]]--;
line[r] = (line[r] ^ x);
col[c] = (col[c] ^ x);
/// n - cate col au val line[r]
fl[line[r]]++;
fc[col[c]]++;
sol = sol + n - fc[line[r]];
sol = sol + n - fl[col[c]];
if (line[r] == col[c])
sol--;
}
int main()
{
FILE *fin = stdin;
FILE *fout = stdout;
int k,p,r,x,i,a,b,c,d;
fscanf (fin,"%d%d%d",&n,&k,&p);
fc[0] = fl[0] = n;
for (i=1;i<=k;i++){
fscanf (fin,"%d%d%d",&r,&c,&x);
mp[make_pair(r,c)] = x;
add(r,c,x);
}
for (i=1;i<=p;i++){
fscanf (fin,"%d%d%d%d",&a,&b,&c,&d);
x = mp[make_pair(a,b)];
mp.erase(make_pair(a,b));
add(a,b,x);
add(c,d,x);
mp[make_pair(c,d)] = x;
fprintf (fout,"%lld\n",sol);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |