Submission #957419

# Submission time Handle Problem Language Result Execution time Memory
957419 2024-04-03T16:33:24 Z Ariadna Topovi (COCI15_topovi) C++14
0 / 120
1328 ms 40368 KB
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int MAX_ROOKS = 2e5;

int main() {
    int n, k, p;
    cin >> n >> k >> p;
    map<int, int> xor_rows, xor_columns;
    map<int, int> cnt_rows, cnt_columns;
    cnt_rows[0] = cnt_columns[0] = n;
    map<pair<int, int>, int> rooks;
    
    ll total = 0;
    while (k--) {
        int r, c, x;
        cin >> r >> c >> x;
        rooks[{r, c}] = x;

        total -= n-cnt_columns[xor_rows[r]];
        total -= n-cnt_rows[xor_columns[c]];
        if (xor_rows[r] ^ xor_columns[c]) ++total;

        cnt_rows[xor_rows[r]]--;
        xor_rows[r] ^= rooks[{r, c}];
        cnt_rows[xor_rows[r]]++;

        cnt_columns[xor_columns[c]]--;
        xor_columns[r] ^= rooks[{r, c}];
        cnt_columns[xor_columns[c]]++;

        total += n-cnt_columns[xor_rows[r]];
        total += n-cnt_rows[xor_columns[c]];
        if (xor_rows[r] ^ xor_columns[c]) --total;
    }

    while (p--) {
        int r1, c1, r2, c2;
        cin >> r1 >> c1 >> r2 >> c2;

        rooks[{r2, c2}] = rooks[{r1, c1}];

        total -= n-cnt_columns[xor_rows[r1]];
        total -= n-cnt_rows[xor_columns[c1]];
        if (xor_rows[r1] ^ xor_columns[c1]) ++total;

        cnt_rows[xor_rows[r1]]--;
        xor_rows[r1] ^= rooks[{r1, c1}];
        cnt_rows[xor_rows[r1]]++;

        cnt_columns[xor_columns[c1]]--;
        xor_columns[r1] ^= rooks[{r1, c1}];
        cnt_columns[xor_columns[c1]]++;

        total += n-cnt_columns[xor_rows[r1]];
        total += n-cnt_rows[xor_columns[c1]];
        if (xor_rows[r1] ^ xor_columns[c1]) --total;

        total -= n-cnt_columns[xor_rows[r2]];
        total -= n-cnt_rows[xor_columns[c2]];
        if (xor_rows[r2] ^ xor_columns[c2]) ++total;

        cnt_rows[xor_rows[r2]]--;
        xor_rows[r2] ^= rooks[{r2, c2}];
        cnt_rows[xor_rows[r2]]++;

        cnt_columns[xor_columns[c2]]--;
        xor_columns[c2] ^= rooks[{r2, c2}];
        cnt_columns[xor_columns[c2]]++;

        total += n-cnt_columns[xor_rows[r2]];
        total += n-cnt_rows[xor_columns[c2]];
        if (xor_rows[r2] ^ xor_columns[c2]) --total;

        rooks.erase({r1, c1});
        cout << total << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Incorrect 162 ms 5820 KB Output isn't correct
7 Incorrect 121 ms 5712 KB Output isn't correct
8 Incorrect 89 ms 4548 KB Output isn't correct
9 Incorrect 92 ms 4692 KB Output isn't correct
10 Incorrect 113 ms 4832 KB Output isn't correct
11 Incorrect 1249 ms 40272 KB Output isn't correct
12 Incorrect 1306 ms 40200 KB Output isn't correct
13 Incorrect 1271 ms 40276 KB Output isn't correct
14 Incorrect 1318 ms 40248 KB Output isn't correct
15 Incorrect 1312 ms 40184 KB Output isn't correct
16 Incorrect 1298 ms 40288 KB Output isn't correct
17 Incorrect 1255 ms 40368 KB Output isn't correct
18 Incorrect 1328 ms 40192 KB Output isn't correct
19 Incorrect 1306 ms 40248 KB Output isn't correct
20 Incorrect 1310 ms 40296 KB Output isn't correct