| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 82819 | xiaowuc1 | Topovi (COCI15_topovi) | C++14 | 1355 ms | 42800 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;
typedef long long ll;
typedef pair<int, int> pii;
map<int, int> rowXOR;
map<int, int> colXOR;
map<int, int> rowF, colF;
map<pii, int> loc;
void change(map<int, int>& m, int k, int v) {
	m[k] += v;
	if(m[k] == 0) m.erase(k);
}
ll ret;
void flip(int x, int y, int v) {
	ret += colF[rowXOR[x]];
	change(rowF, rowXOR[x], -1);
	rowXOR[x] ^= v;
	change(rowF, rowXOR[x], 1);
	ret -= colF[rowXOR[x]];
	if(rowXOR[x] == 0) rowXOR.erase(x);
	ret += rowF[colXOR[y]];
	change(colF, colXOR[y], -1);
	colXOR[y] ^= v;
	change(colF, colXOR[y], 1);
	ret -= rowF[colXOR[y]];
	if(colXOR[y] == 0) colXOR.erase(y);
}
int main() {
	int n, k, p;
	scanf("%d%d%d", &n, &k, &p);
	rowF[0] = n;
	colF[0] = n;
	while(k--) {
		int x, y, v;
		scanf("%d%d%d", &x, &y, &v);
		loc[{x, y}] = v;
		flip(x, y, v);
	}
	while(p--) {
		int xa, ya, xb, yb;
		scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
		int v = loc[{xa, ya}];
		flip(xa, ya, v);
		flip(xb, yb, v);
		loc.erase({xa, ya});
		loc[{xb, yb}] = v;
		printf("%lld\n", ret);
	}
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
