Submission #90769

#TimeUsernameProblemLanguageResultExecution timeMemory
90769vextimeismoney (balkan11_timeismoney)C++14
0 / 100
2 ms1072 KiB
#include <bits/stdc++.h> #define maxn 305 #define pii pair<int,int> using namespace std; int n; int br[maxn]; int brcv=1; vector<int>adj[maxn]; int p[maxn]; int sz[maxn]; int top[maxn]; vector<pair<pii,int>>queries; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin>>n; sz[0]=0; p[0]=0; top[0]=0; br[0]=0; for(int i=1;i<=n;i++) { char x; int a,b; cin>>x; if(x=='c') { cin>>a>>b; br[i]=br[a]; queries.push_back({{a,b},-1}); } else { cin>>a; if(x=='a') { adj[br[a]].push_back(brcv); br[i]=brcv; p[br[i]]=br[a]; sz[br[i]]=sz[br[a]]+1; top[br[i]]=i; brcv++; } else { br[i]=p[br[a]]; queries.push_back({{-1,-1},top[br[a]]}); } } } //for(int i=0;i<=n;i++)cout<<i<<","<<br[i]<<endl; //for(int i=0;i<brcv;i++)cout<<i<<","<<top[i]<<","<<sz[i]<<","<<p[i]<<" "; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...