# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
90769 | vex | timeismoney (balkan11_timeismoney) | C++14 | 2 ms | 1072 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |