제출 #766550

#제출 시각아이디문제언어결과실행 시간메모리
766550Ahmed57크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
100 / 100
414 ms89536 KiB
#include <bits/stdc++.h> using namespace std; void Init(){ return ; } int sz[1000001],chr[1000001]; int P[1000001][20]; int ind = 1; void TypeLetter(char c){ sz[ind] = sz[ind-1]+1; chr[ind] = (c-'a'); P[ind][0] = ind-1; for(int i = 1;i<20;i++){ P[ind][i] = P[P[ind][i-1]][i-1]; } ind++; } void UndoCommands(int u){ int lol = ind-(u+1); sz[ind] = sz[lol]; chr[ind] = chr[lol]; for(int i = 0;i<20;i++){ P[ind][i] = P[lol][i]; } ind++; } char GetLetter(int p){ int xd = sz[ind-1]-(p+1); int cur = ind-1; for(int i = 19;i>=0;i--){ if(xd>=(1<<i)){ cur = P[cur][i]; xd-=(1<<i); } } return char(chr[cur]+'a'); }/* signed main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); init(); TypeLetter('a'); TypeLetter('b'); cout<<GetLetter(1); return 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...