Submission #448732

#TimeUsernameProblemLanguageResultExecution timeMemory
448732IvnFTopovi (COCI15_topovi)C++14
120 / 120
1225 ms45880 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ull unsigned long long #define fi first #define se second #define ld long double ll n, k, p, ans; map<pair<ll, ll>, ll>arr; map<ll, ll>xorbaris, xorkolom, cntbaris, cntkolom; void upd(ll r, ll c, ll val){ ans-=n-cntkolom[xorbaris[r]]; ans-=n-cntbaris[xorkolom[c]]; cntbaris[xorbaris[r]]--; xorbaris[r]^=val; cntbaris[xorbaris[r]]++; cntkolom[xorkolom[c]]--; xorkolom[c]^=val; cntkolom[xorkolom[c]]++; ans+=n-cntkolom[xorbaris[r]]; ans+=n-cntbaris[xorkolom[c]]; arr[{r, c}]^=val; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k >> p; cntbaris[0]=cntkolom[0]=n; for(int i=1;i<=k;++i){ ll r, c, x; cin >> r >> c >> x; upd(r, c, x); } for(int q=0;q<p;++q){ ll r1, r2, c1, c2; cin >> r1 >> c1 >> r2 >> c2; ll x=arr[{r1, c1}]; upd(r1, c1, x); upd(r2, c2, x); cout << ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...