Submission #382497

# Submission time Handle Problem Language Result Execution time Memory
382497 2021-03-27T12:58:05 Z BlancaHM Topovi (COCI15_topovi) C++14
30 / 120
165 ms 65540 KB
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long int ll;

int N, K, P;
long long int attacked;
map<pair<int, int>, int> rooks;
unordered_map<int, int> valRows, valCols, rowXOR, colXOR;

void init() {
	attacked = 0;
	valRows[0] = N;
	valCols[0] = N;
	for (int i = 0; i < N; i++) {
		rowXOR[i] = 0;
		colXOR[i] = 0;
	}
}

void include(int r, int c, int p) {
	attacked -= (ll) (N - valRows[colXOR[c]]);
	attacked -= (ll) (N - valCols[rowXOR[r]]);
	valRows[rowXOR[r]]--;
	valCols[colXOR[c]]--;
	rooks[{r, c}] = p;
	rowXOR[r] ^= p;
	colXOR[c] ^= p;
	valRows[rowXOR[r]]++;
	valCols[colXOR[c]]++;
	attacked += (ll) (N - valRows[colXOR[c]]);
	attacked += (ll) (N - valCols[rowXOR[r]]);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int r, c, p, r2, c2;
	cin >> N >> K >> P;
	init();
	for (int i = 0; i < K; i++) {
		cin >> r >> c >> p;
		include(r-1, c-1, p);
		//cout << attacked << '\n';
	}
	for (int i = 0; i < P; i++) {
		cin >> r >> c >> r2 >> c2;
		p = rooks[{r-1, c-1}];
		include(r-1, c-1, p);
		include(r2-1, c2-1, p);
		cout << attacked << '\n';
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Runtime error 137 ms 65540 KB Execution killed with signal 9
7 Runtime error 142 ms 65540 KB Execution killed with signal 9
8 Runtime error 140 ms 65540 KB Execution killed with signal 9
9 Runtime error 140 ms 65540 KB Execution killed with signal 9
10 Runtime error 144 ms 65540 KB Execution killed with signal 9
11 Runtime error 140 ms 65536 KB Execution killed with signal 9
12 Runtime error 137 ms 65540 KB Execution killed with signal 9
13 Runtime error 143 ms 65540 KB Execution killed with signal 9
14 Runtime error 163 ms 65540 KB Execution killed with signal 9
15 Runtime error 138 ms 65536 KB Execution killed with signal 9
16 Runtime error 138 ms 65540 KB Execution killed with signal 9
17 Runtime error 143 ms 65540 KB Execution killed with signal 9
18 Runtime error 165 ms 65540 KB Execution killed with signal 9
19 Runtime error 145 ms 65540 KB Execution killed with signal 9
20 Runtime error 140 ms 65540 KB Execution killed with signal 9