제출 #589970

#제출 시각아이디문제언어결과실행 시간메모리
589970daria크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
100 / 100
467 ms134216 KiB
#include "bits/stdc++.h" using namespace std; #define ll long long #define N (ll)1e6 ll n = 0, t = 0; ll dpt[N], par[N][21], pos[N]; char c[N]; ll anc(ll a, ll p){ for(ll i=0; i<21; ++i) if(p & (1 <<i)) a = par[a][i]; return a; } void Init(){ } void TypeLetter(char L) { ll curr = pos[t]; n++; t++; pos[t] = n; c[n] = L; dpt[n] = dpt[curr] + 1; par[n][0] = curr; for(ll i=1; i<21; ++i) par[n][i] = par[par[n][i-1]][i-1]; } void UndoCommands(int U) { t++; pos[t] = pos[t-U-1]; } char GetLetter(int P){ ll curr = pos[t]; return c[anc(curr, dpt[curr]-P-1)]; }
#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...