제출 #447869

#제출 시각아이디문제언어결과실행 시간메모리
447869Pietra크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
100 / 100
450 ms75580 KiB
#include<bits/stdc++.h>
using namespace std ; 

const int maxn = 1e6 + 5 ; 
const int maxl = 23 ; 

int n, tempo, t[maxn], h[maxn], tab[maxl][maxn] ; 
char s[maxn] ; 

void TypeLetter(char L) {
   
   n++ ; tempo++ ; 

   t[tempo] = n ; 
   s[n] = L ; 

   tab[0][n] = t[tempo-1] ; 
   h[n] = h[t[tempo-1]] + 1 ; 

   for(int i = 1 ; i < maxl ; i++) tab[i][n] = tab[i-1][tab[i-1][n]] ; 

}
 
void UndoCommands(int U) {

	tempo++ ; 
	t[tempo] = t[tempo - U - 1] ; 

}
 
char GetLetter(int P) {

	int at = t[tempo] ; 
	int alt = h[t[tempo]] - P - 1 ; 

	for(int i = maxl - 1 ; i >= 0 ; i--){
		if(alt >= (1<<i)) alt -= (1<<i), at = tab[i][at] ; 
	}

	return s[at] ; 

}

void Init(){

}
#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...