Submission #268623

#TimeUsernameProblemLanguageResultExecution timeMemory
268623mayhoubsalehTopovi (COCI15_topovi)C++14
120 / 120
1673 ms46032 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; const ll maxn=1e6+100; const ll inf=1e9+10; ll n,k,q; ll unat; map<pair<ll,ll>,ll>a; map<ll,ll>cntr,cntc,valr,valc; void add(ll r,ll c,ll val){ unat-=cntr[valc[c]]; unat-=cntc[valr[r]]; if(valc[c]==valr[r])unat++; cntc[valc[c]]--; cntr[valr[r]]--; valc[c]^=val; valr[r]^=val; cntc[valc[c]]++; cntr[valr[r]]++; unat+=cntc[valr[r]]; unat+=cntr[valc[c]]; if(valr[r]==valc[c])unat--; a[{r,c}]=val; } int main() { IOS cin>>n>>k>>q; cntr[0]=cntc[0]=n; unat=n*n; while(k--){ ll r,c,x; cin>>r>>c>>x; add(r,c,x); } while(q--){ ll r,c,rr,cc; cin>>r>>c>>rr>>cc; ll x=a[{r,c}]; add(r,c,x); add(rr,cc,x); cout<<n*n-unat<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...