제출 #680016

#제출 시각아이디문제언어결과실행 시간메모리
680016Ahmed57크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
100 / 100
689 ms99660 KiB
#include <bits/stdc++.h>

using namespace std;
map<int,char> arr;
int len[1000001];
int mp[1000001];
int op = 0 , root = 0 , node = 0;
int lift[1000001][20];
void Init(){
    mp[op] = root;
}
void TypeLetter(char l){
    node++;
    lift[node][0] = root;
    for(int i = 1;i<20;i++){
        lift[node][i] = lift[lift[node][i-1]][i-1];
    }
    len[node] = len[root]+1;
    root = node;
    op++;
    mp[op] = root;
    arr[root] = l;
}
void UndoCommands(int u){
    mp[op+1] = mp[op-u];
    root = mp[++op];
}
char GetLetter(int p){
    int cc = root;
    p = len[root]-(p+1);
    for(int i = 19;i>=0;i--){
        if(p>=(1<<i)){
            p-=(1<<i);
            cc =lift[cc][i];
        }
    }
    return arr[cc];
}/*
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    Init();
    TypeLetter('a');
    cout<<root<<"\n";
    TypeLetter('b');
    cout<<root<<"\n";
    cout<<GetLetter(1)<<"\n";
    TypeLetter('d');
    cout<<root<<"\n";
    UndoCommands(2);
    cout<<root<<"\n";
    UndoCommands(1);
    cout<<root<<"\n";
    cout<<GetLetter(2)<<"\n";
    TypeLetter('e');
    UndoCommands(1);
    UndoCommands(5);
    TypeLetter('c');
    cout<<GetLetter(2)<<"\n";
    UndoCommands(2);
    cout<<GetLetter(2)<<"\n";
}
*/
#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...