Submission #1017351

# Submission time Handle Problem Language Result Execution time Memory
1017351 2024-07-09T07:32:39 Z vjudge1 Klasika (COCI20_klasika) C++17
33 / 110
75 ms 9328 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 2e3 + 10;
int par[N], val[N], res, cur;
bool in_sub[N][N];
vector<pair<int, int>> g[N];

void dfs(int v, int b, int p = -1){
    if (in_sub[b][v])
        res = max(res, cur);
    for (auto [w, u] : g[v]){
        if (u == p) continue;
        cur ^= w;
        dfs(u, b, v);
        cur ^= w;
    }
}

int main(){
    int q;
    cin >> q;

    int n = 1;
    par[n] = -1;
    in_sub[1][1] = 1;
    while (q--){
        string s;
        cin >> s;

        if (s[0] == 'A'){
            int x, y;
            cin >> x >> y;

            int v = ++n;
            par[v] = x;
            val[v] = y;

            int p = v;
            while (p != -1){
                in_sub[p][v] = 1;
                p = par[p];
            }

            g[x].push_back({y, v});
            g[v].push_back({y, x});
        }
        else{
            int a, b;
            cin >> a >> b;

            res = 0;
            cur = 0;
            dfs(a, b);

            cout << res << endl;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 2904 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 2904 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 6 ms 1368 KB Output is correct
14 Correct 7 ms 2140 KB Output is correct
15 Correct 8 ms 2908 KB Output is correct
16 Correct 8 ms 3676 KB Output is correct
17 Correct 5 ms 1112 KB Output is correct
18 Correct 5 ms 2652 KB Output is correct
19 Correct 6 ms 2936 KB Output is correct
20 Correct 5 ms 3704 KB Output is correct
21 Correct 5 ms 2652 KB Output is correct
22 Correct 6 ms 2652 KB Output is correct
23 Correct 6 ms 2908 KB Output is correct
24 Correct 6 ms 3516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 75 ms 9328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 2904 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 6 ms 1368 KB Output is correct
14 Correct 7 ms 2140 KB Output is correct
15 Correct 8 ms 2908 KB Output is correct
16 Correct 8 ms 3676 KB Output is correct
17 Correct 5 ms 1112 KB Output is correct
18 Correct 5 ms 2652 KB Output is correct
19 Correct 6 ms 2936 KB Output is correct
20 Correct 5 ms 3704 KB Output is correct
21 Correct 5 ms 2652 KB Output is correct
22 Correct 6 ms 2652 KB Output is correct
23 Correct 6 ms 2908 KB Output is correct
24 Correct 6 ms 3516 KB Output is correct
25 Runtime error 75 ms 9328 KB Execution killed with signal 11
26 Halted 0 ms 0 KB -