Submission #164097

# Submission time Handle Problem Language Result Execution time Memory
164097 2019-11-17T12:56:02 Z beso123 Topovi (COCI15_topovi) C++14
60 / 120
2000 ms 39632 KB
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e5+7;
map<int,int> xorr,xorc;
map<int,int> cntr,cntc;
map<pair<int,int>,int> rook;
ll ans = 0;
int n,k,p;
void add(int r,int c,int x){
    rook[{r,c}] ^= x;
    ans -= n-cntc[xorr[r]];
    ans -= n-cntr[xorc[c]];
    if (xorr[r] != xorc[c]) ans++;
    cntc[xorc[c]]--;
    cntr[xorr[r]]--;
    xorr[r] ^= x;
    xorc[c] ^= x;
    cntc[xorc[c]]++;
    cntr[xorr[r]]++;
    ans += n-cntc[xorr[r]];
    ans += n-cntr[xorc[c]];
    if (xorr[r] != xorc[c]) ans--;
}
int main()
{
    cin >> n >> k >> p;
    cntr[0] = n;
    cntc[0] = n;
    rep(i,k)
    {
    	int r,c,x;
    	cin >> r >> c >> x;
    	add(r,c,x);
    }
    while(p--){
    	int r1,c1,r2,c2;
    	cin >> r1 >> c1 >> r2 >> c2;
        int x = rook[{r1,c1}];
    	add(r1,c1,x);
        add(r2,c2,x);
    	cout << ans << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 282 ms 6072 KB Output is correct
7 Correct 216 ms 5348 KB Output is correct
8 Correct 166 ms 4472 KB Output is correct
9 Correct 173 ms 4584 KB Output is correct
10 Correct 193 ms 4728 KB Output is correct
11 Execution timed out 2079 ms 39468 KB Time limit exceeded
12 Execution timed out 2069 ms 39084 KB Time limit exceeded
13 Execution timed out 2083 ms 39220 KB Time limit exceeded
14 Execution timed out 2087 ms 39432 KB Time limit exceeded
15 Execution timed out 2059 ms 39352 KB Time limit exceeded
16 Execution timed out 2077 ms 39568 KB Time limit exceeded
17 Execution timed out 2072 ms 39500 KB Time limit exceeded
18 Execution timed out 2081 ms 39524 KB Time limit exceeded
19 Execution timed out 2069 ms 39632 KB Time limit exceeded
20 Execution timed out 2065 ms 39304 KB Time limit exceeded