Submission #230577

# Submission time Handle Problem Language Result Execution time Memory
230577 2020-05-10T13:13:50 Z soroush Topovi (COCI15_topovi) C++14
6 / 120
2000 ms 45868 KB
#include <bits/stdc++.h>
     
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    typedef pair<int  ,int > pii;
     
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
     
    const ll maxn  = 1e6+100;
    const ll mod =1e9+7;
    const ld PI = acos((ld)-1);
     
    #define pb(x) push_back(x);
    #define endl '\n'
    #define dokme(x) return(cout << x , 0);
    #define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define ms(x , y) memset(x , y , sizeof x);
    #define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
    ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}
     
    map < int , int > cntstr  , cntstn;
    map < pii , int > rook;
    map < int , int > str , stn; 
    ll ans = 0;
    int n , k , p;
     
    void add(int x ,int y , int w){
    	rook[{x , y}]^=w;
    	ans-=n - cntstn[str[x]];
    	ans+=ll(str[x]!=stn[y]);
    	ans -= n - cntstr[stn[y]];
    	cntstr[str[x]]--;
    	cntstn[stn[y]]--;
    	str[x]^=w;
    	stn[y]^=w;
    	cntstr[str[x]]++;
    	cntstn[stn[y]]++;
    	ans-=ll(str[x]!=stn[y]);
    	ans += n - cntstn[str[x]];
    	ans += n - cntstr[stn[y]];
    }
     
    int main(){
        migmig
        cin >> n >> k >> p;
        cntstr[0] = cntstn[0] = n;
        for(int i = 0 ; i < n; i ++){
    		int x , y;
    		cin >> x >> y;
    		int w;
    		cin >> w;
    		add(x , y , w);
    	}
        while(p--){
    		int x1 , y1 , x2 , y2;
    		cin >> x1 >> y1 >> x2 >> y2;
    		int val = rook[{x1 , y1}];
    		add(x1 , y1 , val);
    		add(x2 , y2 , val);
    		cout << ans << endl;
    	}
        return(0);
    }
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Incorrect 5 ms 384 KB Output isn't correct
5 Incorrect 5 ms 384 KB Output isn't correct
6 Incorrect 1161 ms 8264 KB Output isn't correct
7 Incorrect 639 ms 6904 KB Output isn't correct
8 Incorrect 900 ms 5752 KB Output isn't correct
9 Incorrect 931 ms 5752 KB Output isn't correct
10 Incorrect 979 ms 6392 KB Output isn't correct
11 Execution timed out 2084 ms 45688 KB Time limit exceeded
12 Execution timed out 2088 ms 45696 KB Time limit exceeded
13 Execution timed out 2078 ms 45776 KB Time limit exceeded
14 Execution timed out 2089 ms 45688 KB Time limit exceeded
15 Execution timed out 2090 ms 45868 KB Time limit exceeded
16 Execution timed out 2086 ms 45772 KB Time limit exceeded
17 Execution timed out 2090 ms 45676 KB Time limit exceeded
18 Execution timed out 2087 ms 45560 KB Time limit exceeded
19 Execution timed out 2086 ms 45724 KB Time limit exceeded
20 Execution timed out 2083 ms 45712 KB Time limit exceeded