Submission #61833

#TimeUsernameProblemLanguageResultExecution timeMemory
61833theknife2001Crayfish scrivener (IOI12_scrivener)C++17
12 / 100
251 ms5668 KiB
#include <bits/stdc++.h>
#define ii pair < char , char >
#define fi first
#define se second


using namespace std;
const int N=1e6+5;
ii a[N];
char s[N];
int cnt;
int i;


void Init() {}

void TypeLetter(char L) {
    a[i].fi='T';
    a[i].se=L;
    i++;
}

void UndoCommands(int U) {
    a[i].fi='U';
    a[i].se='0'+U;
    i++;
}

char GetLetter(int P) {
    if(cnt==0)
    {
        for(int k=0;k<i;k++)
        if(a[k].fi!='U'&&a[k].fi!='T')
        assert(0);
        int j=0;
        for(int k=i-1;k>=0;k--)
        {
            if(a[k].fi=='T')
            {
                s[j]=a[k].se;
                j++;
            }
            else if(a[k].fi=='U')
            {
                k-=(a[k].se-'0');
            }
//            else if(a[k].fi==0)
//                assert(0);
        }
        reverse(s,s+j);
    }
//    cnt=1;
    return s[P];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...