Submission #1131599

#TimeUsernameProblemLanguageResultExecution timeMemory
1131599Szymon_PilipczukDungeons Game (IOI21_dungeons)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
int j[19][400001][3];
void init(int n,int* s,int* p,int* w,int* l)
{
    for(int i = 0;i<n;i++)
    {
        j[0][i][0] = w[i];
        j[0][i][1] = s[i];
        j[0][i][2] = s[i];
    }
    j[0][n][0] = n;
    j[0][n][1] = 0;
    j[0][n][2] = 0;
    for(int w = 0;w<19;w++)
    {
        for(int i = 0;i<n;i++)
        {
            j[w][i][0] = j[w-1][j[w-1][i][0]][0];
            j[w][i][1] = max(j[w-1][i][1],j[w-1][j[w-1][i][0]][2] - j[w-1][i][2]);
            j[w][i][2] = j[w-1][i][2] + j[w-1][j[w-1][i][0]][2];
        }
    }
}
int64_t simulate(int x,int z)
{
    while(x != n)
    {
        for(int w = 18;w>=0;w--)
        {
            if(j[w][x][1] <=z)
            {
                z += j[w][x][2];
                x = j[w][x][0];
            }
        }
        if(x != n)
        {
            z+= p[x];
            x = l[x];
        }
    }
    return z;
}

Compilation message (stderr)

dungeons.cpp: In function 'int64_t simulate(int, int)':
dungeons.cpp:27:16: error: 'n' was not declared in this scope
   27 |     while(x != n)
      |                ^
dungeons.cpp:39:17: error: 'p' was not declared in this scope
   39 |             z+= p[x];
      |                 ^
dungeons.cpp:40:17: error: 'l' was not declared in this scope
   40 |             x = l[x];
      |                 ^