# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
448732 | IvnF | Topovi (COCI15_topovi) | C++14 | 1225 ms | 45880 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |