Submission #820150

#TimeUsernameProblemLanguageResultExecution timeMemory
820150BT21tataCrayfish scrivener (IOI12_scrivener)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

int que, up[1000006][21], len[1000006];
char c[1000006];

void Init() {}

void TypeLetter(char L)
{
    que++;
    c[que]=L;
    up[que][0]=que-1;
    len[que]=len[que-1]+1;
    for(int i=1; i<21; i++)
        up[que][i]=up[up[que][i-1]][i-1];
}

void UndoCommands(int U)
{
    que++;
    len[que]=len[que-1-U];
    c[que]=c[que-1-U]
    for(int i=0; i<21; i++)
        up[que][i]=up[que-1-U][i];
}

char GetLetter(int p)
{
    p=len[que]-1-p;
    int cur=que;
    for(int i=20; i>=0; i--)
    {
        if(p-(1<<i)>=0)
        {
            p-=(1<<i);
            cur=up[cur][i];
        }
    }
    return c[cur];
}

Compilation message (stderr)

scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:23:22: error: expected ';' before 'for'
   23 |     c[que]=c[que-1-U]
      |                      ^
      |                      ;
   24 |     for(int i=0; i<21; i++)
      |     ~~~               
scrivener.cpp:24:18: error: 'i' was not declared in this scope
   24 |     for(int i=0; i<21; i++)
      |                  ^