Submission #1285182

#TimeUsernameProblemLanguageResultExecution timeMemory
1285182FaggiDungeons Game (IOI21_dungeons)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define ll long long
#define sz(x) int(x.size())
#define forn(i, n) for (i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define fr first
#define se second
using namespace std;

const int MAXN = 4e5 + 1;
const int LOG = 20;

ll ma[MAXN][LOG], up2[MAXN][LOG], sum2[MAXN][LOG];
ll up3[25][MAXN][LOG], sum3[25][MAXN][LOG];
vector<int> S, P, W, L, dif;
int N;
void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l)
{

    s.pb(0);
    p.pb(0);
    w.pb(n);
    l.pb(n);
    ll i, j;
    N = n;
    S = s;
    P = p;
    W = w;
    L = l;

    map<ll, bool> m;
    for (i = 0; i < n; i++)
    {
        if (m[s[i]] == 0)
            dif.pb(s[i]);
        m[s[i]] = 1;
    }

    sort(all(dif));
    for (i = 0; i <= n; i++)
    {
        up2[i][0] = w[i];
        ma[i][0] = s[i];
        sum2[i][0] = s[i];
        for (j = 0; j < sz(dif); j++)
        {
            ll x, y;
            if(s[i]<dif[j])
            {
                x=w[i];
                y=s[i];
            }
            else
            {
                x=l[i];
                y=p[i];
            }
            up3[j][i][0]=x;
            sum3[j][i][0]=y;
        }
    }

    for (i = 1; i < LOG; i++)
    {
        for (j = 0; j <= n; j++)
        {
            up2[j][i] = up2[up2[j][i - 1]][i - 1];
            sum2[j][i] = sum2[j][i - 1] + sum2[up2[j][i - 1]][i - 1];
            ma[j][i] = max(ma[j][i - 1], ma[up2[j][i - 1]][i - 1]);
            for (ll k = 0; k < sz(dif); k++)
            {
                up3[k][j][i]=up3[k][up3[k][j][i-1]][i-1];
                sum3[k][j][i]=sum3[k][j][i-1]+sum3[k][up3[k][j][i-1]][i-1];
            }
        }
    }
    return;
}

long long simulate(int x, int z)
{
    ll act = z, i, ult;
    while (x != N)
    {
        if (1ll * S[x] <= act)
        {
            ll aum = 0;
            for (i = LOG - 1; i >= 0; i--)
            {
                if (ma[x][i] <= act)
                {
                    aum += sum2[x][i];
                    x = up2[x][i];
                }
            }
            act += aum;
        }
        else
        {
            ll pos=0;
            for(i=0; i<sz(dif); i++)
            {
                if(dif[i]<=act)
                {
                    pos++;
                }
            }

            for(i=LOG-1; i>=0; i--)
            {
                if(sum3[pos][x][i]+act<dif[pos])
                {
                    act+=sum3[pos][x][i];
                    x=up3[pos][x][i];
                }
            }
            act+=sum3[pos][x][0];
            x=up3[pos][x][0];
        }
    }
    return act;
}

Compilation message (stderr)

/tmp/cci3ARQe.o: in function `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> >)':
dungeons.cpp:(.text+0xd72): relocation truncated to fit: R_X86_64_PC32 against symbol `up2' defined in .bss section in /tmp/cci3ARQe.o
dungeons.cpp:(.text+0xd8b): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/cci3ARQe.o
dungeons.cpp:(.text+0xd96): relocation truncated to fit: R_X86_64_PC32 against symbol `sum2' defined in .bss section in /tmp/cci3ARQe.o
dungeons.cpp:(.text+0xfb2): relocation truncated to fit: R_X86_64_PC32 against symbol `up2' defined in .bss section in /tmp/cci3ARQe.o
dungeons.cpp:(.text+0xfb9): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/cci3ARQe.o
dungeons.cpp:(.text+0xfc0): relocation truncated to fit: R_X86_64_PC32 against symbol `sum2' defined in .bss section in /tmp/cci3ARQe.o
dungeons.cpp:(.text+0x1018): relocation truncated to fit: R_X86_64_PC32 against symbol `up2' defined in .bss section in /tmp/cci3ARQe.o
dungeons.cpp:(.text+0x1039): relocation truncated to fit: R_X86_64_PC32 against symbol `sum2' defined in .bss section in /tmp/cci3ARQe.o
dungeons.cpp:(.text+0x1058): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/cci3ARQe.o
/tmp/cci3ARQe.o: in function `simulate(int, int)':
dungeons.cpp:(.text+0x16b2): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/cci3ARQe.o
dungeons.cpp:(.text+0x16b9): 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