Submission #115751

#TimeUsernameProblemLanguageResultExecution timeMemory
115751fadi57Topovi (COCI15_topovi)C++14
120 / 120
1627 ms40120 KiB
#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() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 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 timeMemoryGrader output
Fetching results...