Submission #541969

# Submission time Handle Problem Language Result Execution time Memory
541969 2022-03-24T22:29:01 Z Olympia Topovi (COCI15_topovi) C++17
0 / 120
2000 ms 58252 KB
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#include <cmath>
#include <map>
#include <random>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <limits.h>
#include <queue>

using namespace std;
const int MOD = 10007;
class DynamicThing {
    map<int,int> oc1;
    map<int,int> oc2;
public:
    int tot = 0;
    void remove (int type, int index, int quantity) {
        if (type == 1) {
            tot -= oc1[index] * oc2[index];
            oc1[index] -= quantity;
            tot += oc1[index] * oc2[index];
        } else {
            tot -= oc1[index] * oc2[index];
            oc2[index] -= quantity;
            tot += oc1[index] * oc2[index];
        }
    }
    void add (int type, int index, int quantity) {
        if (type == 1) {
            tot -= oc1[index] * oc2[index];
            oc1[index] += quantity;
            tot += oc1[index] * oc2[index];
        } else {
            tot -= oc1[index] * oc2[index];
            oc2[index] += quantity;
            tot += oc1[index] * oc2[index];
        }
    }
};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    map<int,int> row_xor;
    map<int,int> col_xor;
    int N, K, P;
    cin >> N >> K >> P;
    DynamicThing dt;
    dt.add(1, 0, N);
    dt.add(2, 0, N);
    map<pair<int,int>,int> loc;
    for (int i = 0; i < N; i++) {
        int r, c, x;
        cin >> r >> c >> x;
        dt.remove(1, row_xor[r], 1 );
        dt.remove(2, col_xor[c], 1);
        row_xor[r] ^= x;
        col_xor[r] ^= x;
        dt.add(1, row_xor[r], 1 );
        dt.add(2, col_xor[c], 1);
        loc[{r, c}] = x;
    }
    while (P--) {
        int r1, c1, r2, c2;
        cin >> r1 >> c1 >> r2 >> c2;
        dt.remove(1, row_xor[r1], 1 );
        dt.remove(2, col_xor[c1], 1);
        dt.remove(1, row_xor[r2], 1 );
        dt.remove(2, col_xor[c2], 1);
        row_xor[r1] ^= loc[{r1, c1}];
        col_xor[c1] ^= loc[{r1, c1}];
        row_xor[r2] ^= loc[{r1, c1}];
        col_xor[c2] ^= loc[{r1, c1}];
        dt.add(1, row_xor[r1], 1 );
        dt.add(2, col_xor[c1], 1);
        dt.add(1, row_xor[r2], 1 );
        dt.add(2, col_xor[c2], 1);
        cout << N * N - dt.tot << '\n';
    }
    //cout << dt.tot << '\n';

}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Incorrect 1 ms 340 KB Output isn't correct
6 Incorrect 867 ms 9536 KB Output isn't correct
7 Incorrect 503 ms 7872 KB Output isn't correct
8 Incorrect 691 ms 6524 KB Output isn't correct
9 Incorrect 659 ms 6708 KB Output isn't correct
10 Incorrect 753 ms 7232 KB Output isn't correct
11 Execution timed out 2081 ms 58032 KB Time limit exceeded
12 Execution timed out 2089 ms 57984 KB Time limit exceeded
13 Execution timed out 2079 ms 57892 KB Time limit exceeded
14 Execution timed out 2087 ms 58060 KB Time limit exceeded
15 Execution timed out 2084 ms 57956 KB Time limit exceeded
16 Execution timed out 2075 ms 58076 KB Time limit exceeded
17 Execution timed out 2073 ms 57972 KB Time limit exceeded
18 Execution timed out 2092 ms 58024 KB Time limit exceeded
19 Execution timed out 2084 ms 58252 KB Time limit exceeded
20 Execution timed out 2015 ms 57916 KB Time limit exceeded