Submission #357159

#TimeUsernameProblemLanguageResultExecution timeMemory
357159daniel920712Crayfish scrivener (IOI12_scrivener)C++14
34 / 100
1096 ms8736 KiB
#include <stack>
#include <vector>
using namespace std;
char last;
int con[1000005]={0};
int now=0;
int how=0;
stack < char > ans;
vector < char > tt;
vector < pair < int , int > > all;
void Init()
{

}

void TypeLetter(char L)
{
    all.push_back(make_pair(1,L));
    now++;
}

void UndoCommands(int U)
{
    all.push_back(make_pair(2,U));
    now++;
}

char GetLetter(int P)
{
    int t,i;
    how=0;
    tt.clear();
    for(i=now-1;i>=0;i--)
    {
        if(how)
        {
            how--;
            continue;
        }
        if(all[i].first==1) ans.push(all[i].second);
        else how+=all[i].second;
    }
    while(!ans.empty())
    {
        tt.push_back(ans.top());
        ans.pop();
    }
    return tt[P];

}

Compilation message (stderr)

scrivener.cpp: In function 'char GetLetter(int)':
scrivener.cpp:30:9: warning: unused variable 't' [-Wunused-variable]
   30 |     int t,i;
      |         ^
#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...