Submission #646924

#TimeUsernameProblemLanguageResultExecution timeMemory
646924gnhmhpCrayfish scrivener (IOI12_scrivener)C++17
Compilation error
0 ms0 KiB
#define taskname "typing."
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr)
#include <bits/stdc++.h>
using namespace std;

const int maxn=1e6+1;
int sz[maxn], q, cver=0;

struct node
{
    node* left;
    node* right;
    char c;
    node()
    {
        left=right=nullptr;
    }
} root=node();
node* ver[maxn];

void build(node *p, int l, int r)
{
    if (l==r) return;
    int mid=(l+r)/2;
    p->left=new node();
    p->right=new node();
    build(p->left, l, mid);
    build(p->right, mid+1, r);
}

node* update(node* i, int l, int r, int x, char ch)
{
    node* cur=new node();
    if (l==r)
    {
        cur->c=ch;
        return cur;
    }
    int mid=(l+r)/2;
    cur=i;
    if (x<=mid)
        cur->left=update(i->left, l, mid, x, ch);
    else
        cur->right=update(i->right, mid+1, r, x, ch);
    return cur;
}

char get(node* i, int l, int r, int x)
{
    if (l==r) return i->c;
    int mid=(l+r)/2;
    if (x<=mid) return get(i->left, l, mid, x);
    return get(i->right, mid+1, r, x);
}

int main()
{
    fastio;
    cin >> q;
    build(&root, 0, q);
    sz[0]=-1; ver[0]=&root;
    for (int i=1; i<=q; ++i)
    {
        char t; int x;
        cin >> t;
        if (t=='T')
        {
            cin >> t;
            sz[cver+1]=sz[cver]+1;
            ver[cver+1]=update(ver[cver], 0, q, sz[cver+1], t);
            ++cver;
        }
        else if (t=='U')
        {
            cin >> x;
            ver[cver+1]=ver[cver-x];
            sz[cver+1]=sz[cver-x];
            ++cver;
        }
        else
        {
            cin >> x;
            cout << get(ver[cver], 0, q, x) << '\n';
        }
    }

}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccTdKrFm.o: in function `main':
scrivener.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccWjkhTo.o:grader.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccWjkhTo.o: in function `main':
grader.cpp:(.text.startup+0x63): undefined reference to `Init()'
/usr/bin/ld: grader.cpp:(.text.startup+0xff): undefined reference to `TypeLetter(char)'
/usr/bin/ld: grader.cpp:(.text.startup+0x15f): undefined reference to `UndoCommands(int)'
/usr/bin/ld: grader.cpp:(.text.startup+0x18b): undefined reference to `GetLetter(int)'
collect2: error: ld returned 1 exit status