Submission #1299310

#TimeUsernameProblemLanguageResultExecution timeMemory
1299310Faisal_SaqibDungeons Game (IOI21_dungeons)C++20
Compilation error
0 ms0 KiB
// #include <vector>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=4e5+1,LG=25;
const ll inf=1e18;
ll n,s[N],p[N],w[N],l[N];
ll nxt[LG][N][LG],inc[LG][N][LG],th[LG][N][LG];
void init(int n2, std::vector<int> s1, std::vector<int> p1, std::vector<int> w1, std::vector<int> l1)
{
    n=n2;
    for(int i=0;i<n;i++)
    {
        s[i]=s1[i];
        p[i]=p1[i];
        w[i]=w1[i];
        l[i]=l1[i];
    }
    s[n]=p[n]=0;
    w[n]=l[n]=n;
    for(int k=0;k<LG;k++)
    {
        ll pw=1ll<<k;
        // assume 2^k <= z < 2^(k+1)
        // for all si < 2^k we win
        for(int j=0;j<=n;j++)
        {
            if(s[j]<=pw)
            {
                nxt[k][j][0]=w[j];
                inc[k][j][0]=s[j];
                th[k][j][0]=inf;
            }
            else
            {
                nxt[k][j][0]=l[j];
                inc[k][j][0]=p[j];
                th[k][j][0]=s[j];
                // if z>=th[j] then we could have won at stage 
            }
        }
        for(int j=1;j<LG;j++)
        {
            for(int i=0;i<=n;i++)
            {
                nxt[k][i][j]=nxt[k][nxt[k][i][j-1]][j-1];
                inc[k][i][j]=inc[k][i][j-1] + inc[k][nxt[k][i][j-1]][j-1];
                th[k][i][j]=min(th[k][i][j-1],th[k][nxt[k][i][j-1]][j-1] - inc[k][i][j-1]);
            }
        }
    }
}
long long simulate(int x1, int z1)
{
	long long z=z1,x=x1;
    ll pw=1,lg=0;
	while(x!=n)
	{
        while((pw*2)<=z)
        {
            pw*=2;
            lg++;
        }
        lg=min(lg,24ll);
        for(int j=LG-1;j>=0;j--)
        {
            if(th[lg][x][j]>z) // we dont win 
            {
                z+=inc[lg][x][j];
                x=nxt[lg][x][j];
            }
        }
        if(s[x]<=z)
        {
            z+=s[x];
            x=w[x];
        }
        else
        {
            z+=p[x];
            x=l[x];
        }
	}
	return z;
}

Compilation message (stderr)

/tmp/ccHLh10K.o: in function `main':
grader.cpp:(.text.startup+0x14a): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x151): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x16f): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x176): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x185): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x18c): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x198): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x19f): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x1ab): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x1b2): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x1be): additional relocation overflows omitted from the output
/usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(ios_init.o): in function `std::ios_base::Init::Init()':
(.text._ZNSt8ios_base4InitC2Ev+0x1f): failed to convert GOTPCREL relocation against '_ZNSt8ios_base4Init11_S_refcountE'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x1ed): failed to convert GOTPCREL relocation against '_ZSt4cout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x252): failed to convert GOTPCREL relocation against '_ZSt3cin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x2bc): failed to convert GOTPCREL relocation against '_ZSt4cerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x316): failed to convert GOTPCREL relocation against '_ZSt4clog'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x50f): failed to convert GOTPCREL relocation against '_ZSt5wcout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x57d): failed to convert GOTPCREL relocation against '_ZSt4wcin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x5f0): failed to convert GOTPCREL relocation against '_ZSt5wcerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x654): failed to convert GOTPCREL relocation against '_ZSt5wclog'; relink with --no-relax
/usr/bin/ld: final link failed
collect2: error: ld returned 1 exit status