# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
321614 | nikatamliani | Crayfish scrivener (IOI12_scrivener) | C++14 | 1051 ms | 71900 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, A = 26;
int nodes = 0, pos;
int code[N][A], depth[N];
pair<int, char> par[N];
vector<int> v;
void TypeLetter(char c) {
if(!code[pos][c - 'a']) {
code[pos][c - 'a'] = ++nodes;
par[nodes] = {pos, c};
depth[nodes] = depth[pos] + 1;
}
v.push_back(code[pos][c - 'a']);
pos = v.back();
}
void UndoCommands(int x) {
assert((int)v.size() - 1 - x >= 0);
pos = v[(int)v.size() - 1 - x];
v.push_back(pos);
}
char GetLetter(int index) {
int size = depth[pos];
int up = size - index - 1;
int answer = pos;
while(depth[answer] != index + 1) {
answer = par[answer].first;
}
return par[answer].second;
}
void Init() {
}
// int main() {
// int k;
// cin >> k;
// while(k--) {
// int type;
// cin >> type;
// if(type == 1) {
// char c;
// cin >> c;
// TypeLetter(c);
// } else if(type == 2) {
// int x;
// cin >> x;
// UndoCommands(x);
// } else {
// int x;
// cin >> x;
// cout << GetLetter(x) << ' ';
// }
// }
// }
Compilation message (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... |