제출 #130660

#제출 시각아이디문제언어결과실행 시간메모리
130660dragonslayerit크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
100 / 100
715 ms93944 KiB
#include <string>

struct String{
  int len;
  char last;
  int prev[20];
  String():len(0),last('\0'){
  }
}str[1000001];
int curr=0;


void Init() {}

void TypeLetter(char L) {
  str[curr+1].len=str[curr].len+1;
  str[curr+1].last=L;
  str[curr+1].prev[0]=curr;
  for(int k=1;k<20;k++){
    str[curr+1].prev[k]=str[str[curr+1].prev[k-1]].prev[k-1];
  }
  curr++;
}

void UndoCommands(int U) {
  str[curr+1]=str[curr-U];
  curr++;
}

char GetLetter(int P) {
  int move=str[curr].len-1-P;
  int x=curr;
  for(int k=0;k<20;k++){
    if(move&(1<<k)){
      x=str[x].prev[k];
    }
  }
  return str[x].last;
}
#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...