# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1017790 |
2024-07-09T10:13:29 Z |
vjudge1 |
Klasika (COCI20_klasika) |
C++17 |
|
5000 ms |
8848 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N=2e5+5;
int const mod=1e9+7;
vector<pair<int,int>> adj[N];
int par1[N];
int n=1;
int ss=0;
int ans=0;
void dfs1(int node,int xr=0,bool vs=0,int p=0){
if(node==ss)
vs=1;
if(vs)
ans=max(ans,xr);
for(auto [c,w]:adj[node]){
if(c!=p)
dfs1(c,xr^(w),vs,node);
}
}
void dfs2(int node,int xr=0,int p=0){
ans=max(ans,xr);
if(node==ss)
return;
for(auto [c,w]:adj[node]){
if(c!=p)
dfs2(c,xr^(w),node);
}
}
int main(){
int q;
cin>>q;
while(q--){
string s;
cin>>s;
if(s=="Add"){
n++;
int u,w;
cin>>u>>w;
par1[n]=u;
adj[u].push_back({n,w});
adj[n].push_back({u,w});
}
else{
int a,b;
cin>>a>>b;
int p=par1[a];
bool bl=0;
while(p!=0){
if(p==b)
bl=1;
p=par1[p];
}
if(bl){
ss=b;
dfs2(a);
cout<<ans<<endl;
ans=0;
ss=0;
}
else{
ss=b;
dfs1(a,0,0);
cout<<ans<<endl;
ans=0;
ss=0;
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5027 ms |
8848 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |