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>
using namespace std;
string s;
vector<int>borr;
set<pair<int,string>>se;
bool band=1;
void Init()
{
s="";
}
void TypeLetter(char L)
{
s+=L;
borr.push_back(0);
}
void UndoCommands(int U)
{
auto it=se.lower_bound({(int(borr.size())-U),""});
se.insert({(int(borr.size())),s});
if(it!=se.end())
{
pair<int,string>pa=*it;
int falt= U-(int(borr.size())-pa.first);
s=pa.second;
s.resize(int(s.size())-falt);
}
else
s.resize(int(s.size())-(U));
borr.push_back(U);
}
void arm()
{
string res="";
for(int i=int(s.size())-1; i>=0; i--)
{
if(s[i]!='0')
{
res+=s[i];
}
else
{
i-=borr[i];
}
}
s="";
for(int i=int(res.size())-1; i>=0; i--)
{
s+=res[i];
}
}
char GetLetter(int P)
{
if(band)
arm();
band=0;
return s[P];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |