# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
382496 |
2021-03-27T12:53:36 Z |
BlancaHM |
Topovi (COCI15_topovi) |
C++14 |
|
645 ms |
37356 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;
}
void include(int r, int c, int p) {
int xorRow = 0, xorCol = 0;
if (colXOR.find(c) != colXOR.end())
xorCol = colXOR[c];
if (rowXOR.find(r) != rowXOR.end())
xorRow = rowXOR[r];
attacked -= (ll) (N - valRows[xorCol]);
attacked -= (ll) (N - valCols[xorRow]);
valRows[xorRow]--;
valCols[xorCol]--;
rooks[{r, c}] = p;
xorRow ^= p;
xorCol ^= p;
if (xorRow > 0) rowXOR[r] = xorRow;
if (xorCol > 0) colXOR[c] = xorCol;
valRows[xorRow]++;
valCols[xorCol]++;
attacked += (ll) (N - valRows[xorCol]);
attacked += (ll) (N - valCols[xorRow]);
}
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);
}
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 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
364 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
6 |
Incorrect |
59 ms |
4844 KB |
Output isn't correct |
7 |
Incorrect |
43 ms |
4460 KB |
Output isn't correct |
8 |
Incorrect |
37 ms |
3840 KB |
Output isn't correct |
9 |
Incorrect |
36 ms |
3916 KB |
Output isn't correct |
10 |
Incorrect |
44 ms |
3948 KB |
Output isn't correct |
11 |
Incorrect |
617 ms |
37160 KB |
Output isn't correct |
12 |
Incorrect |
615 ms |
37240 KB |
Output isn't correct |
13 |
Incorrect |
622 ms |
37244 KB |
Output isn't correct |
14 |
Incorrect |
615 ms |
37304 KB |
Output isn't correct |
15 |
Incorrect |
609 ms |
37240 KB |
Output isn't correct |
16 |
Incorrect |
603 ms |
37240 KB |
Output isn't correct |
17 |
Incorrect |
636 ms |
37356 KB |
Output isn't correct |
18 |
Incorrect |
603 ms |
37196 KB |
Output isn't correct |
19 |
Incorrect |
618 ms |
37172 KB |
Output isn't correct |
20 |
Incorrect |
645 ms |
37296 KB |
Output isn't correct |