# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
98583 | 2019-02-24T15:24:04 Z | Mercenary | Topovi (COCI15_topovi) | C++14 | 1310 ms | 34348 KB |
#include<bits/stdc++.h> using namespace std; #define taskname "TEST" #define pb push_back typedef long double ld; typedef long long ll; const int maxn = 1e5 + 5; map<int,int> mcol , mrow; map<int,int> cntcol , cntrow; int n , p , k; map<pair<int,int>,int> mmap; #define mp make_pair ll res = 0; void Move(int r , int c , int val){ int &valr = mrow[r];int &valc = mcol[c]; if(valr != valc)res++; res -= 2 * n - cntrow[valc] - cntcol[valr]; cntcol[valc]--; cntrow[valr]--; valr ^= val;valc ^= val; cntcol[valc]++; cntrow[valr]++; res += 2 * n - cntrow[valc] - cntcol[valr]; if(valr != valc)res--; mmap[mp(r,c)] ^= val; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")) freopen(taskname".INP", "r",stdin) , freopen(taskname".OUT", "w",stdout); cin >> n >> k >> p; cntcol[0] = cntrow[0] = n; for(int i = 1 ; i <= k ; ++i) { int r , c , x; cin >> r >> c >> x; Move(r,c,x); } for(int i = 1 ; i <= p ; ++i){ int r1 , c1 , r2 , c2;cin >> r1 >> c1 >> r2 >> c2; int val = mmap[mp(r1,c1)]; Move(r1,c1,val); Move(r2,c2,val); cout << res << '\n'; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 111 ms | 5880 KB | Output is correct |
7 | Correct | 87 ms | 5368 KB | Output is correct |
8 | Correct | 85 ms | 4468 KB | Output is correct |
9 | Correct | 71 ms | 4728 KB | Output is correct |
10 | Correct | 71 ms | 4856 KB | Output is correct |
11 | Correct | 1255 ms | 34272 KB | Output is correct |
12 | Correct | 1280 ms | 34288 KB | Output is correct |
13 | Correct | 1226 ms | 34296 KB | Output is correct |
14 | Correct | 1200 ms | 34348 KB | Output is correct |
15 | Correct | 1243 ms | 34236 KB | Output is correct |
16 | Correct | 1203 ms | 34336 KB | Output is correct |
17 | Correct | 1305 ms | 34184 KB | Output is correct |
18 | Correct | 1310 ms | 34168 KB | Output is correct |
19 | Correct | 1229 ms | 34324 KB | Output is correct |
20 | Correct | 1207 ms | 34260 KB | Output is correct |