# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
431734 | luka1234 | Crayfish scrivener (IOI12_scrivener) | C++14 | 0 ms | 0 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 ll long long
#define ff first
#define ss second
using namespace std;
int siz[1000001];
char adg[1000001];
int main(){
int n;
cin>>n;
set<int> s;
int mn=1e9;
vector<pair<pair<char,char>,int> > a;
for(int k=1;k<=n;k++){
char c;
cin>>c;
if(c=='T'){
char c1;
cin>>c1;
a.push_back({{'T',c1},-1});
}
if(c=='U'){
int v;
cin>>v;
a.push_back({{'U','S'},v});
}
if(c=='P'){
int v;
cin>>v;
s.insert(v);
}
}
for(int k=0;k<a.size();k++){
char c=a[k].ff.ff;
if(c=='T'){
char c1=a[k].ff.ss;
siz[k+1]=siz[k]+1;
int v=siz[k+1]-1;
if(s.find(v)!=s.end())
adg[v]=c1;
}
if(c=='U'){
int v=a[k].ss;
siz[k+1]=siz[k-v];
}
}
set<int>::iterator it;
for(it=s.begin();it!=s.end();it++){
int v=*it;
cout<<adg[v]<<"\n";
}
return 0;
}