제출 #747798

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

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

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

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

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

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