# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
844518 |
2023-09-05T13:47:57 Z |
vjudge1 |
Klasika (COCI20_klasika) |
C++17 |
|
5000 ms |
10776 KB |
#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define int long long
using namespace std;
const int inf = 2e18 + 5;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
vector<pair<int, int> > adj[N];
vector<int> child[N];
map<int,int> vis;
vector<pair<int,int> > val;
void dfs(int node, int ih){
if(vis[node]) return;
vis[node] = 1;
val.pb({ih, node});
for(auto itr: adj[node]){
dfs(itr.first, (ih ^ itr.second));
}
}
map<int,int> c;
void cbul(int node){
c[node] = 1;
for(auto itr: child[node]) cbul(itr);
}
int32_t main(){
//freopen("in.txt","r", stdin);
int q;
cin>>q;
int ncnt = 1;
while(q--){
string s;
cin>>s;
if(s == "Add"){
int x, y;
cin>>x>>y;
ncnt++;
adj[ncnt].pb({x, y});
adj[x].pb({ncnt, y});
child[x].pb(ncnt);
}
else{
int a, b;
cin>>a>>b;
vis.clear();
c.clear();
val.clear();
int ans = 0;
dfs(a, 0);
cbul(b);
for(auto itr: val){
if(c[itr.second]){
ans = max(ans, itr.first);
}
}
cout<<ans<<endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
9816 KB |
Output is correct |
2 |
Correct |
3 ms |
9816 KB |
Output is correct |
3 |
Correct |
3 ms |
9816 KB |
Output is correct |
4 |
Correct |
3 ms |
9816 KB |
Output is correct |
5 |
Correct |
4 ms |
9816 KB |
Output is correct |
6 |
Correct |
4 ms |
9816 KB |
Output is correct |
7 |
Correct |
4 ms |
9816 KB |
Output is correct |
8 |
Correct |
3 ms |
9816 KB |
Output is correct |
9 |
Correct |
3 ms |
9816 KB |
Output is correct |
10 |
Correct |
3 ms |
9820 KB |
Output is correct |
11 |
Correct |
5 ms |
9968 KB |
Output is correct |
12 |
Correct |
3 ms |
9816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
9816 KB |
Output is correct |
2 |
Correct |
3 ms |
9816 KB |
Output is correct |
3 |
Correct |
3 ms |
9816 KB |
Output is correct |
4 |
Correct |
3 ms |
9816 KB |
Output is correct |
5 |
Correct |
4 ms |
9816 KB |
Output is correct |
6 |
Correct |
4 ms |
9816 KB |
Output is correct |
7 |
Correct |
4 ms |
9816 KB |
Output is correct |
8 |
Correct |
3 ms |
9816 KB |
Output is correct |
9 |
Correct |
3 ms |
9816 KB |
Output is correct |
10 |
Correct |
3 ms |
9820 KB |
Output is correct |
11 |
Correct |
5 ms |
9968 KB |
Output is correct |
12 |
Correct |
3 ms |
9816 KB |
Output is correct |
13 |
Correct |
56 ms |
9932 KB |
Output is correct |
14 |
Correct |
80 ms |
10068 KB |
Output is correct |
15 |
Correct |
90 ms |
10064 KB |
Output is correct |
16 |
Correct |
61 ms |
10072 KB |
Output is correct |
17 |
Correct |
90 ms |
9816 KB |
Output is correct |
18 |
Correct |
152 ms |
9904 KB |
Output is correct |
19 |
Correct |
144 ms |
10064 KB |
Output is correct |
20 |
Correct |
106 ms |
10028 KB |
Output is correct |
21 |
Correct |
81 ms |
9892 KB |
Output is correct |
22 |
Correct |
130 ms |
10416 KB |
Output is correct |
23 |
Correct |
129 ms |
10020 KB |
Output is correct |
24 |
Correct |
85 ms |
10328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5031 ms |
10776 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
9816 KB |
Output is correct |
2 |
Correct |
3 ms |
9816 KB |
Output is correct |
3 |
Correct |
3 ms |
9816 KB |
Output is correct |
4 |
Correct |
3 ms |
9816 KB |
Output is correct |
5 |
Correct |
4 ms |
9816 KB |
Output is correct |
6 |
Correct |
4 ms |
9816 KB |
Output is correct |
7 |
Correct |
4 ms |
9816 KB |
Output is correct |
8 |
Correct |
3 ms |
9816 KB |
Output is correct |
9 |
Correct |
3 ms |
9816 KB |
Output is correct |
10 |
Correct |
3 ms |
9820 KB |
Output is correct |
11 |
Correct |
5 ms |
9968 KB |
Output is correct |
12 |
Correct |
3 ms |
9816 KB |
Output is correct |
13 |
Correct |
56 ms |
9932 KB |
Output is correct |
14 |
Correct |
80 ms |
10068 KB |
Output is correct |
15 |
Correct |
90 ms |
10064 KB |
Output is correct |
16 |
Correct |
61 ms |
10072 KB |
Output is correct |
17 |
Correct |
90 ms |
9816 KB |
Output is correct |
18 |
Correct |
152 ms |
9904 KB |
Output is correct |
19 |
Correct |
144 ms |
10064 KB |
Output is correct |
20 |
Correct |
106 ms |
10028 KB |
Output is correct |
21 |
Correct |
81 ms |
9892 KB |
Output is correct |
22 |
Correct |
130 ms |
10416 KB |
Output is correct |
23 |
Correct |
129 ms |
10020 KB |
Output is correct |
24 |
Correct |
85 ms |
10328 KB |
Output is correct |
25 |
Execution timed out |
5031 ms |
10776 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |