제출 #1232964

#제출 시각아이디문제언어결과실행 시간메모리
1232964clemmy14크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++20
60 / 100
1096 ms31648 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);
	// if(texts.size() == 0) {
	// 	string prev; prev.push_back(L);
	// 	texts.push_back(L);
	// } else {
	// 	string prev=texts[texts.size()-1]; prev.push_back(L);
	// 	texts.push_back(prev);
	// }
	parent.push_back(parent.size()-1);
	first=0;
}

void UndoCommands(int U) {
	texts.push_back(' ');
	parent.push_back(parent.size()-U-1);
	// string prev=texts[texts.size()-U-1];
	// texts.push_back(prev);
	first=0;
}

char GetLetter(int P) {
	// cout << ans << endl;
	// cout << texts << endl;
	// for(auto x : parent) cout << x << ' ';
	// cout << endl;
	//return texts[texts.size()-1][P];

	if(first == 0) {
		int id=texts.size()-1;
		while(id != -1) {
			if(texts[id] != ' ') ans.push_back(texts[id]);
			id=parent[id];
		}
		reverse(ans.begin(), ans.end());
		first++;
	}


	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...