제출 #747802

#제출 시각아이디문제언어결과실행 시간메모리
747802ThegeekKnight16Crayfish scrivener (IOI12_scrivener)C++17
100 / 100
947 ms87336 KiB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
const int MAXK = 21;
vector<char> v; vector<int> tam;
int dp[MAXK][MAXN];
int id = 0;

void Init()
{
    v.push_back('-');
    tam.push_back(-1);
}

void TypeLetter(char L)
{
    v.push_back(L);
    tam.push_back(tam.back()+1);
    ++id;
    dp[0][id] = id-1;

    for (int k = 1; k < MAXK; k++) dp[k][id] = dp[k-1][ dp[k-1][id] ];
}

void UndoCommands(int U)
{
    tam.push_back(tam[id-U]);
    v.push_back('X');
    dp[0][id+1] = id-U;
    ++id;
    for (int k = 1; k < MAXK; k++) dp[k][id] = dp[k-1][ dp[k-1][id] ];
}

char GetLetter(int P)
{
    int X = id;
    for (int k = MAXK-1; k >= 0; k--)
    {
        if (tam[dp[k][X]] >= P) X = dp[k][X];
    }
    return v[X];
}
#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...