Submission #115750

# Submission time Handle Problem Language Result Execution time Memory
115750 2019-06-08T20:12:30 Z fadi57 Topovi (COCI15_topovi) C++14
114 / 120
2000 ms 46072 KB
#include <bits/stdc++.h>
using namespace std;
 

 
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-



ll n,z,k,t,ans,m,l,j;


map<ll,ll>r,c,xr,xc;
map<pair<ll,ll>,ll>h;

ll up(ll x,ll y,ll o){
  
   ans-=(n-(xc[r[x]]));
     ans-=(n-(xr[c[y]]));
     if(r[x]==c[y]){ans++;}
     xr[r[x]]--;
     r[x]^=o; //cout<<r[x]^o;
     xc[c[y]]--; 
     c[y]^=o;
     xr[r[x]]++;
     xc[c[y]]++;
     ans+=(n-(xc[r[x]]));
     ans+=(n-(xr[c[y]]));
 if(r[x]==c[y]){ans--;}
ll kk=9;return kk;
    

}
int main()
{
  
  

  cin>>n>>m>>t; 
  xr[0]=xc[0]=n;
  for(ll i=0;i<m;i++){
     ll x,y;
cin>>x>>y>>z; h[{x,y}]=z;

up(x,y,z);
  }

for(ll i=1;i<=t;i++){ 
   ll x,y;
cin>>x>>y>>j>>l;
ll o=h[{x,y}]; h[{x,y}]=0;up(x,y,o);up(j,l,o);
cout<<ans<<endl;h[{j,l}]=o;

  }
  return 0;
  
     

   }
# 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 2 ms 384 KB Output is correct
4 Correct 17 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 216 ms 7132 KB Output is correct
7 Correct 164 ms 6300 KB Output is correct
8 Correct 137 ms 5100 KB Output is correct
9 Correct 145 ms 5240 KB Output is correct
10 Correct 163 ms 5536 KB Output is correct
11 Correct 1912 ms 45992 KB Output is correct
12 Correct 1911 ms 45876 KB Output is correct
13 Correct 1928 ms 45792 KB Output is correct
14 Correct 1908 ms 45964 KB Output is correct
15 Execution timed out 2040 ms 45984 KB Time limit exceeded
16 Correct 1931 ms 46072 KB Output is correct
17 Correct 1935 ms 45924 KB Output is correct
18 Correct 1915 ms 45988 KB Output is correct
19 Correct 1930 ms 45920 KB Output is correct
20 Correct 1878 ms 45864 KB Output is correct