제출 #760713

#제출 시각아이디문제언어결과실행 시간메모리
760713fatemetmhr크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
100 / 100
280 ms87140 KiB
// ~ Be Name Khoda ~ // #include <bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC target("avx2") //#pragma GCC optimize("unroll-loops,Ofast") using namespace std; typedef long long ll; #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fi first #define se second const int maxn = 1e6 + 10; const int maxn5 = 1e6 + 10; const int maxnt = 1.2e6 + 10; const int maxn3 = 1e3 + 10; const int mod = 1e9 + 7; const int lg = 20; const ll inf = 1e18; int cur, newnode = 1, pt = 0, st[maxn5]; int par[lg][maxn5], h[maxn5]; char op[maxn5], parchar[maxn5]; void Init(){ cur = 0; memset(par, -1, sizeof par); h[0] = 0; } void TypeLetter(char l){ //cout << "ok we are in " << l << ' ' << cur << ' ' << endl; op[pt] = l; int v = newnode++; par[0][v] = cur; h[v] = h[cur] + 1; for(int i = 1; i < lg && par[i - 1][v] != -1; i++) par[i][v] = par[i - 1][par[i - 1][v]]; parchar[v] = l; cur = v; st[pt++] = cur; //cout << "now in " << cur << endl; } void UndoCommands(int t){ //cout << "undo from " << cur << endl; op[pt++] = 'U'; cur = st[pt - t - 2]; st[pt - 1] = cur; //cout << "to " << t << ' ' << cur << ' ' << st[0] << endl; } char GetLetter(int pos){ //cout << "while in " << cur << ' ' << pos << ' ' << h[cur] << endl; int d = h[cur] - pos - 1; int v = cur; for(int i = 0; i < lg; i++) if((d >> i)&1) v = par[i][v]; return parchar[v]; } /* 6 T a T b T d U 2 U 1 P 2 */
#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...