제출 #260128

#제출 시각아이디문제언어결과실행 시간메모리
260128uacoder123크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
100 / 100
616 ms170720 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; int t[1000000][26],par[1000000][32],co=1,lev[1000000]; vi v; char c[1000000]; void Init() { v.pb(0); for(int i=0;i<32;++i) par[0][i]=0; lev[0]=0; } void TypeLetter(char L) { if(t[v.back()][L-'a']==0) { t[v.back()][L-'a']=co; par[co][0]=v.back(); c[co]=L; lev[co]=lev[v.back()]+1; for(int i=1;i<32;++i) par[co][i]=par[par[co][i-1]][i-1]; v.pb(co); co++; } else v.pb(t[v.back()][L-'a']); } void UndoCommands(int U) { v.pb(v[v.size()-U-1]); } char GetLetter(int P) { P++; int p=lev[v.back()]-P,cur=v.back(),b=0; while((1LL<<b)<=p) { if(bit(p,b)) cur=par[cur][b]; b++; } return(c[cur]); }
#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...