# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153933 | 2019-09-17T14:16:12 Z | Ruxandra985 | Topovi (COCI15_topovi) | C++14 | 1750 ms | 33400 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 187 ms | 4856 KB | Output is correct |
7 | Correct | 153 ms | 4524 KB | Output is correct |
8 | Correct | 121 ms | 3844 KB | Output is correct |
9 | Correct | 115 ms | 3832 KB | Output is correct |
10 | Correct | 133 ms | 3876 KB | Output is correct |
11 | Correct | 1597 ms | 33220 KB | Output is correct |
12 | Correct | 1609 ms | 33348 KB | Output is correct |
13 | Correct | 1589 ms | 33268 KB | Output is correct |
14 | Correct | 1611 ms | 33112 KB | Output is correct |
15 | Correct | 1588 ms | 33200 KB | Output is correct |
16 | Correct | 1661 ms | 33260 KB | Output is correct |
17 | Correct | 1590 ms | 33312 KB | Output is correct |
18 | Correct | 1604 ms | 33192 KB | Output is correct |
19 | Correct | 1750 ms | 33284 KB | Output is correct |
20 | Correct | 1689 ms | 33400 KB | Output is correct |