제출 #1348351

#제출 시각아이디문제언어결과실행 시간메모리
1348351comgaTramAnh크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++20
100 / 100
553 ms68352 KiB
#include <bits/stdc++.h>
using namespace std;
int num_commands;
int depth[1000005];
int tree_node[1000005];
char tree_letter[1000005];
int cur_node;
int num_nodes;
int jump[22][1000005];
void Init() {
  cur_node = 0;
  num_nodes = 0;
}
void TypeLetter(char L) {
  num_nodes++;
  tree_letter[num_nodes] = L;
  depth[num_nodes] = depth[cur_node] + 1;
  num_commands++;
  tree_node[num_commands] = num_nodes;
  jump[0][num_nodes] = cur_node;
  for (int j = 1; j < 22; j++) {
    jump[j][num_nodes] = jump[j - 1][jump[j - 1][num_nodes]];
  }
  cur_node = tree_node[num_commands];
}
void UndoCommands(int U) {
  num_commands++;
  tree_node[num_commands] = tree_node[num_commands - U - 1];
  cur_node = tree_node[num_commands];
}
char GetLetter(int P) {
  int ans_node = cur_node;
  for (int j = 21; j >= 0; j--) {
    int cand = jump[j][ans_node];
    if (depth[cand] > P) {
      ans_node = cand;
    }
  }
  return tree_letter[ans_node];
}
#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...