Submission #1131598

#TimeUsernameProblemLanguageResultExecution timeMemory
1131598Szymon_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 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:4:23: error: expected ',' or '...' before 's'
    4 | void init(int n,int[] s,int[] p,int[] w,int[] l)
      |                       ^
dungeons.cpp: In function 'void init(int, int*)':
dungeons.cpp:8:22: error: 'w' was not declared in this scope
    8 |         j[0][i][0] = w[i];
      |                      ^
dungeons.cpp:9:22: error: 's' was not declared in this scope
    9 |         j[0][i][1] = s[i];
      |                      ^
dungeons.cpp: At global scope:
dungeons.cpp:25:1: error: 'int64' does not name a type; did you mean 'int64_t'?
   25 | int64 simulate(int x,int z)
      | ^~~~~
      | int64_t