제출 #1009011

#제출 시각아이디문제언어결과실행 시간메모리
1009011vqpahmad크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
100 / 100
455 ms86612 KiB
#include<bits/stdc++.h>
using namespace std;
#ifdef ONPC
#include"debug.h"
#else
#define debug(...) 42
#endif
#define endl '\n'
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
const int mod = 1e9 + 7;
const int MAXN = 1e6 + 15;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int len[MAXN];
int st[MAXN][20];
char letter[MAXN];
int pos = 1;

void Init() {

}

void TypeLetter(char L) {
	pos++;
	len[pos] = len[pos - 1] + 1;
	letter[pos] = L;
	st[pos][0] = pos - 1;
	for (int b = 1; b < 20; b++)
		st[pos][b] = st[st[pos][b - 1]][b - 1];
}

void UndoCommands(int U) {
	pos++;
	len[pos] = len[pos - U - 1];
	letter[pos] = '*';
	st[pos][0] = pos - U - 1;
	for (int b = 1; b < 20; b++)
		st[pos][b] = st[st[pos][b - 1]][b - 1];
}

char GetLetter(int P) {
	P++;
	int cur = pos;
	// we want the Pth letter
	for (int b = 19; b >= 0; b--){
		if (len[st[cur][b]] >= P) cur = st[cur][b];
	}
	return letter[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...