#include <bits/stdc++.h>
using namespace std;
const int MAX_LOG = 20;
const int MAX_SIZE = 26;
struct Node{
char val;
int depth;
vector<Node*> figli;
Node* father[MAX_LOG];
Node(char val, int depth) : val(val), depth(depth){
figli.resize(MAX_SIZE, nullptr);
for(int i=0; i<MAX_LOG; i++)
father[i] = nullptr;
}
Node(char val, int depth, Node* N) : val(val), depth(depth){
figli.resize(MAX_SIZE, nullptr);
father[0] = N;
for(int i=1; i<MAX_LOG; i++)
if(father[i-1] != nullptr)
father[i] = father[i-1]->father[i-1];
else
father[i] = nullptr;
}
};
Node* root;
vector<Node*> version;
void Init() {
root = new Node('\0', -1);
version.push_back(root);
}
void TypeLetter(char L) {
//aggiungi la lettera come nuova versione
if(version.back()->figli[L-'a'] == nullptr){
version.back()->figli[L-'a'] = new Node(L, version.back()->depth+1, version.back());
}
version.push_back(version.back()->figli[L-'a']);
}
void UndoCommands(int U) {
version.push_back(version[version.size()-U-1]);
}
char GetLetter(int P) {
Node* node = version.back();
int L = version.back()->depth - P;
for(int i=0; (1<<i)<=L; i++)if(L&(1<<i))
node = node->father[i];
return node->val;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
476 KB |
Output is correct |
3 |
Correct |
2 ms |
476 KB |
Output is correct |
4 |
Correct |
2 ms |
476 KB |
Output is correct |
5 |
Correct |
2 ms |
476 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
504 KB |
Output is correct |
8 |
Correct |
2 ms |
504 KB |
Output is correct |
9 |
Correct |
2 ms |
504 KB |
Output is correct |
10 |
Correct |
2 ms |
552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
552 KB |
Output is correct |
2 |
Correct |
2 ms |
564 KB |
Output is correct |
3 |
Correct |
2 ms |
568 KB |
Output is correct |
4 |
Correct |
2 ms |
696 KB |
Output is correct |
5 |
Correct |
2 ms |
696 KB |
Output is correct |
6 |
Correct |
2 ms |
696 KB |
Output is correct |
7 |
Correct |
2 ms |
712 KB |
Output is correct |
8 |
Correct |
2 ms |
712 KB |
Output is correct |
9 |
Correct |
2 ms |
712 KB |
Output is correct |
10 |
Correct |
2 ms |
712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1140 KB |
Output is correct |
2 |
Correct |
4 ms |
1264 KB |
Output is correct |
3 |
Correct |
3 ms |
1304 KB |
Output is correct |
4 |
Correct |
4 ms |
1844 KB |
Output is correct |
5 |
Correct |
3 ms |
1844 KB |
Output is correct |
6 |
Correct |
5 ms |
2280 KB |
Output is correct |
7 |
Correct |
4 ms |
2280 KB |
Output is correct |
8 |
Correct |
4 ms |
2280 KB |
Output is correct |
9 |
Correct |
4 ms |
2280 KB |
Output is correct |
10 |
Correct |
3 ms |
2280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
784 ms |
251284 KB |
Output is correct |
2 |
Runtime error |
766 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
802 ms |
263168 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 |
Halted |
0 ms |
0 KB |
- |