제출 #151952

#제출 시각아이디문제언어결과실행 시간메모리
151952karma크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
5 / 100
282 ms69220 KiB
#include <bits/stdc++.h> #define ll long long #define pb emplace_back #define mp make_pair #define fi first #define se second using namespace std; const int N = int(1e6) + 1; const int logN = 21; int cur, p[N][logN], ver[N], len[N]; char c[N]; void Init() {cur = 0;} void TypeLetter(char ch) { ver[cur] = cur, c[cur] = ch; p[cur][0] = cur? cur - 1: cur; len[cur] = len[p[cur][0]] + 1; for(int i = 1; i < logN; ++i) p[cur][i] = p[p[cur][i - 1]][i - 1]; ++cur; } void UndoCommands(int k) { ver[cur] = ver[cur - k - 1]; len[cur] = len[ver[cur]]; c[cur] = c[ver[cur]]; ++cur; } char GetLetter(int k) { int pos = ver[cur - 1]; k = len[pos] - k - 1; for(int i = logN - 1; i >= 0; --i) if((k >> i) & 1) pos = p[pos][i]; return c[pos]; } //int main() //{ // ios_base::sync_with_stdio(0); // cin.tie(0), cout.tie(0); // if(fopen("test.inp", "r")) { // freopen("test.inp", "r", stdin); // freopen("test.out", "w", stdout); // } // Init(); // TypeLetter('a');// a // TypeLetter('b');// ab // cout << GetLetter(1) << '\n';// b ab // TypeLetter('d');// abd // UndoCommands(2);// a // UndoCommands(1);// abd // cout << GetLetter(2) << '\n';// d abd // TypeLetter('e');// abde // UndoCommands(1);// abd // UndoCommands(5);// ab // TypeLetter('c');// abc // cout << GetLetter(2) << '\n';// c abc // UndoCommands(2);// abd // cout << GetLetter(2) << '\n';// d abd //}
#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...