제출 #430829

#제출 시각아이디문제언어결과실행 시간메모리
430829rumen_m크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
26 / 100
222 ms13208 KiB
# include <bits/stdc++.h>
using namespace std;
char last;
vector <char> t;
vector <int> pos;
vector <int> par;
stack <char> st;
bool fl = false;
int prevv=-1, ver=-1;
vector <char> w;
void Init() {
prevv = -1;
ver = -1;
t.clear();
pos.clear();
par.clear();
//st.clear();
fl = false;
}

void TypeLetter(char L) {

  last = L;
    ver++;
    pos.push_back(ver);
    t.push_back(L);
    par.push_back(prevv);
    prevv = ver;
}

void UndoCommands(int U) {
    int k = pos[pos.size()-U-1];
    pos.push_back(k);
    prevv = k;
}

char GetLetter(int P) {
    if(!fl)
    {
        for(int i = prevv; i!=-1; i =par[i])
        {
            st.push(t[i]);
        }
        while(!st.empty())
        {
            w.push_back(st.top());
            st.pop();
        }
        fl= true;
    }
    return w[P];
  //return last;

}
#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...