제출 #1232987

#제출 시각아이디문제언어결과실행 시간메모리
1232987clemmy14크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++20
60 / 100
1095 ms7208 KiB
#include<bits/stdc++.h>
using namespace std;

int first=0;
string ans, texts;
vector<int> parent;

void Init() {

}

void TypeLetter(char L) {
	texts.push_back(L);

	int par = parent.size()-1;
	if(par != -1 && texts[par] == ' ') par=parent[par];
	parent.push_back(par);

	first=0;
}

void UndoCommands(int U) {
	texts.push_back(' ');

	int par = parent.size()-U-1;
	if(texts[par] == ' ') par=parent[par];
	parent.push_back(par);

	first=0;
}

char GetLetter(int P) {
	if(first == 0) {
		ans.clear();
		int id=texts.size()-1;
		while(id != -1) {
			ans.push_back(texts[id]);
			id=parent[id];
		}
		reverse(ans.begin(), ans.end());
		first++;
	}
	// for(auto x : parent) cout << x << ' ';
	// cout << endl;
	return ans[P];
}
#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...