Submission #769971

# Submission time Handle Problem Language Result Execution time Memory
769971 2023-06-30T15:27:04 Z vjudge1 Klasika (COCI20_klasika) C++17
0 / 110
5000 ms 4680 KB
//YOU WILL MAKE IT
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+2;
int ans=0;
vector<pair<int,int>> graph[N];
int pa[N];
void dfs(int i,int j,int p,int cur,bool f){
    if(f)
     ans=max(ans,cur);
    for(auto h:graph[i]){
        int x=h.first;
        if((x==p)||(x==pa[j]&&f)) continue;
        dfs(x,j,i,cur^(h.second),(f|(x==j)));
    }
}
void solve(){
  int q;cin>>q;
  int n=2;
  while(q--){
    string s;cin>>s;
    int x,y;cin>>x>>y;
    if(s[0]=='A'){
        graph[n].push_back({x,y});
        graph[x].push_back({n,y});
        pa[n]=x;
        n++;
    }
    else{
        ans=0;
        dfs(x,y,-1,0,(x==y));
        cout<<ans<<endl;
    }
  }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
   int t=1;
   // cin>>t;
    while(t--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5020 ms 4680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -