Submission #426804

#TimeUsernameProblemLanguageResultExecution timeMemory
426804dxz05Crayfish scrivener (IOI12_scrivener)C++14
100 / 100
851 ms102084 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 3e2; int prv[N], id[N], len[N]; int commands = 0, up[N][22]; char ch[N]; void Init() { } void TypeLetter(char L) { commands++; id[commands] = commands; int x = id[commands]; prv[x] = max(1, id[commands - 1]); ch[x] = L; len[x] = len[prv[x]] + 1; up[x][0] = prv[x]; for (int i = 1; i < 22; i++){ up[x][i] = up[up[x][i - 1]][i - 1]; } //cout << "\t" << commands << ' ' << L << endl; } void UndoCommands(int U) { commands++; id[commands] = id[commands - U - 1]; } char GetLetter(int P) { P++; int x = id[commands]; for (int i = 21; i >= 0; i--){ if (len[up[x][i]] >= P) x = up[x][i]; } return ch[x]; } /** 14 T a T b P 1 T d U 2 U 1 P 2 T e U 1 U 5 T c P 2 U 2 P 2 5 T a U 1 U 1 U 2 P 0 */
#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...