| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 98695 | Dat160601 | Topovi (COCI15_topovi) | C++17 | 1397 ms | 33600 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 mp make_pair
#define pb push_back
#define fi first
#define se second
long long n, ans;
int k, p, r, c, x;
map <int, int> cnt[2], val[2];
map < pair <int, int>, int > a;
void update(int tp, int pos, int v){
	int cur = val[tp][pos];
	ans += 1LL * cnt[0][cur] * cnt[1][cur];
	cnt[tp][cur]--;
	ans -= 1LL * cnt[0][cur] * cnt[1][cur];
	cur ^= v;
	val[tp][pos] = cur;
	ans += 1LL * cnt[0][cur] * cnt[1][cur];
	cnt[tp][cur]++;
	ans -= 1LL * cnt[0][cur] * cnt[1][cur];
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k >> p;
	cnt[0][0] = cnt[1][0] = n;
	while(k --){
		cin >> r >> c >> x;
		a[mp(r, c)] = x;
		update(0, r, x), update(1, c, x);
	}
	while(p --){
		int ar, ac;
		cin >> r >> c >> ar >> ac;
		x = a[mp(r, c)];
		a[mp(r, c)] = 0, a[mp(ar, ac)] = x;
		update(0, r, x), update(1, c, x);
		update(0, ar, x), update(1, ac, x);
		cout << ans << "\n";
	}
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
