답안 #65745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
65745 2018-08-08T16:28:50 Z aquablitz11 크레이피쉬 글쓰는 기계 (IOI12_scrivener) C++14
0 / 100
1000 ms 263168 KB
#include <bits/stdc++.h>
using namespace std;

const int n = 1e6;
struct node {
    char c;
    node *l, *r;
    node(char c) : c(c), l(0), r(0) {}
    node(node *l, node *r) : c(0), l(l), r(r) {}
};

node *build(int b=0, int e=n-1)
{
    if (b == e) return new node(0);
    int m = (b+e)/2;
    return new node(build(b, m), build(m+1, e));
}

node *update(int i, char c, node *p, int b=0, int e=n-1)
{
    if (b==e) return new node(c);
    int m = (b+e)/2;
    if (i <= m)
        return new node(update(i, c, p->l, b, m), p->r);
    else
        return new node(p->l, update(i, c, p->r, m+1, e));
}

char get(int i, node *p, int b=0, int e=n-1)
{
    if (b == e) return p->c;
    int m = (b+e)/2;
    if (i <= m)
        return get(i, p->l, b, m);
    else
        return get(i, p->r, m+1, e);
}

const int V = 1e6+1;
int vc = 0;
int len[V];
node *ptr[V];

void Init() {
    printf("Init()\n");
    len[0] = 0;
    ptr[0] = build();
}

void TypeLetter(char L) {
    printf("TypeLetter(%c)\n", L);
    ++vc;
    len[vc] = len[vc-1]+1;
    ptr[vc] = update(len[vc-1], L, ptr[vc-1]);
}

void UndoCommands(int U)
{
    printf("UndoCommands(%d)\n", U);
    U = min(U, vc);
    ++vc;
    len[vc] = len[vc-U-1];
    ptr[vc] = ptr[vc-U-1];
}

char GetLetter(int P)
{
    char ans = get(P, ptr[vc]);
    printf("GetLetter(%d) = %c\n", P, ans);
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 109 ms 62968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 117 ms 63228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 115 ms 64176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1097 ms 263168 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1020 ms 263168 KB Time limit exceeded
2 Halted 0 ms 0 KB -