# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
516115 | 600Mihnea | 크레이피쉬 글쓰는 기계 (IOI12_scrivener) | C++17 | 1094 ms | 149848 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
class Vertex {
private:
Vertex* kids[26];
Vertex* father;
int len;
char lastChar;
public:
Vertex() :
len(0),
father(nullptr),
lastChar('#') {
for (int i = 0; i < 26; i++) kids[i] = nullptr;
}
Vertex* addChar(char ch) {
int id = ch - 'a';
assert(0 <= ch && ch <= 'z');
if (!kids[id]) {
kids[id] = new Vertex;
kids[id]->len = len + 1;
kids[id]->father = this;
kids[id]->lastChar = ch;
}
return kids[id];
}
int query(int p) {
assert(lastChar != '#');
if (p == len - 1) {
return lastChar;
} else {
return father->query(p);
}
}
};
class VertexHandler {
private:
vector<Vertex*> history;
public:
VertexHandler() {
history.push_back(new Vertex);
}
void undoHistory(int t) {
int version = (int) history.size() - 1 - t;
assert(0 <= version && version < (int) history.size());
history.push_back(history[version]);
}
void addChar(char ch) {
cout << "start\n";
history.push_back(history.back()->addChar(ch));
cout << "end\n";
}
int query(int p) {
cout << "L\n";
int S = history.back()->query(p);
cout << "R\n";
return S;
}
} vertexHandler;
char last;
void Init() {}
void TypeLetter(char L) {
vertexHandler.addChar(L);
last = L;
}
void UndoCommands(int U) {
vertexHandler.undoHistory(U);
}
char GetLetter(int P) {
return vertexHandler.query(P);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |