# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
154138 | 2019-09-18T14:18:59 Z | Linca_Robert | Topovi (COCI15_topovi) | C++14 | 1618 ms | 34492 KB |
#include<bits/stdc++.h> using namespace std; int N, K, P; map<int,int> rxor, cxor, cntr, cntc; map< pair<int,int>, int > A; long long sol = 0; inline void moverk( int r, int c, int x ){ sol -= N - cntc[ rxor[r] ]; sol -= N - cntr[ cxor[c] ]; if( cxor[c] != rxor[r] ) sol++; cntr[ rxor[r] ]--; rxor[r] ^= x; cntr[ rxor[r] ]++; cntc[ cxor[c] ]--; cxor[c] ^= x; cntc[ cxor[c] ]++; sol += N - cntc[ rxor[r] ]; sol += N - cntr[ cxor[c] ]; if( cxor[c] != rxor[r] ) sol--; A[make_pair( r, c )] ^= x; } int main(){ scanf( "%d%d%d", &N, &K, &P ); cntr[0] = cntc[0] = N; for( int i = 1; i <= K; i++ ){ int r, c, x; scanf( "%d%d%d", &r, &c, &x ); r--, c--; moverk( r, c, x ); } for( int i = 1; i <= P; i++ ){ int r1, c1, r2, c2; scanf( "%d%d%d%d", &r1, &c1, &r2, &c2 ); r1--, c1--, r2--, c2--; int x = A[ make_pair( r1, c1 ) ]; moverk( r1, c1, x ); moverk( r2, c2, x ); printf( "%lld\n", sol ); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 173 ms | 5612 KB | Output is correct |
7 | Correct | 136 ms | 5112 KB | Output is correct |
8 | Correct | 107 ms | 4216 KB | Output is correct |
9 | Correct | 117 ms | 4368 KB | Output is correct |
10 | Correct | 142 ms | 4472 KB | Output is correct |
11 | Correct | 1516 ms | 34048 KB | Output is correct |
12 | Correct | 1520 ms | 34492 KB | Output is correct |
13 | Correct | 1539 ms | 34132 KB | Output is correct |
14 | Correct | 1570 ms | 33976 KB | Output is correct |
15 | Correct | 1554 ms | 33952 KB | Output is correct |
16 | Correct | 1607 ms | 34144 KB | Output is correct |
17 | Correct | 1506 ms | 33988 KB | Output is correct |
18 | Correct | 1539 ms | 33980 KB | Output is correct |
19 | Correct | 1545 ms | 34116 KB | Output is correct |
20 | Correct | 1618 ms | 34152 KB | Output is correct |