Submission #1131601

#TimeUsernameProblemLanguageResultExecution timeMemory
1131601Szymon_PilipczukDungeons Game (IOI21_dungeons)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
int j[19][400001][3];
int n;
int s[400000];
int p[400000];
int w[400000];
int l[400000];
void init(int nt,int* st,int* pt,int* wt,int* lt)
{
    n = nt;
    for(int i =0 ;i<n;i++)
    {
        s[i] = st[i];
        p[i] = pt[i];
        w[i] = wt[i];
        l[i] = lt[i];
    }
    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)

/usr/bin/ld: /tmp/ccK3PNYO.o: in function `main':
grader.cpp:(.text.startup+0x39c): undefined reference to `init(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status