제출 #1368381

#제출 시각아이디문제언어결과실행 시간메모리
1368381po_rag526크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++20
100 / 100
371 ms174720 KiB
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+67;
pair<char,int> up[N][22];
int sz[N],cnt=1;
void Init() {
}

void TypeLetter(char L) {
    sz[cnt]=sz[cnt-1]+1;
    up[cnt][0]={L,cnt};
    for(int i=1;i<22;i++){
        up[cnt][i]=up[up[cnt][i-1].second-1][i-1];
    }
    cnt++;
}

void UndoCommands(int U) {
    int take=cnt-U-1;
    for(int i=0;i<22;i++)up[cnt][i]=up[take][i];
    sz[cnt]=sz[take];
    cnt++;
}

char GetLetter(int P) {
    int take=cnt-1;
    int jump=sz[take]-P-1;
   // cout<<jump<<endl;
   // return 'a';
    for(int i=21;i>=0;i--){
        if((1<<i)<=jump){
            jump-=(1<<i);
            take=up[take][i].second-1;
        }
    }
    return up[take][0].first;
}
//ez
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…