Submission #104390

# Submission time Handle Problem Language Result Execution time Memory
104390 2019-04-06T11:09:55 Z dfistric Crayfish scrivener (IOI12_scrivener) C++14
0 / 100
350 ms 158936 KB
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)

using namespace std;

struct node {
    node* ch[30];
    node* par;
    node* jump;
    char c;
    int dep;

    node(node* n, node* nn, char cc) {
        REP(i, 26) ch[i] = 0;
        par = n, jump = nn, c = cc;

        if (n) dep = n->dep + 1;
        else   dep = 0;
    }
};
node* root;

vector <node*> ve;
int flag;
string s;

void Init() {
    root = new node(NULL, NULL, '.');
    ve.push_back(root);

    return;
}

node* go_up(int x) {
    node* curr = root;

    while (curr->dep > x) {
        int d = curr->dep;
        int ne = curr->dep - (d & -d);
        if (ne >= x) curr = curr->jump;
        else         curr = curr->par;
    }

    return curr;
}

void TypeLetter(char L) {
    flag = 1;

    int x = (L - 'a');
    int nd = root->dep + 1;
    nd = nd & -nd;
    if (!root->ch[x]) root->ch[x] = new node(root, go_up(nd - 1), L);
    root = root->ch[x];
    ve.push_back(root);

    return;
}

void UndoCommands(int U) {
    flag = 1;

    root = ve[ve.size() - 1 - U];
    ve.push_back(root);

    return;
}

char GetLetter(int P) {
    node* curr = go_up(P + 1);
    return curr->c;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 294 ms 158936 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 350 ms 138532 KB Output isn't correct
2 Halted 0 ms 0 KB -