Submission #981426

# Submission time Handle Problem Language Result Execution time Memory
981426 2024-05-13T07:57:59 Z 12345678 Dungeons Game (IOI21_dungeons) C++17
11 / 100
838 ms 1205696 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=5e4+5, kx=24;

ll N, pw[kx];
vector<ll> S(nx), P(nx), W(nx), L(nx);

struct edge
{
    ll out, cost, t;
    edge(ll out=0, ll cost=0, ll t=0): out(out), cost(cost), t(t){}
} dp[kx][nx][kx];

void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) {
    N=n;
    pw[0]=1;
    for (int i=1; i<kx; i++) pw[i]=pw[i-1]*2;
    for (int i=0; i<n; i++) S[i]=s[i], P[i]=p[i], W[i]=w[i], L[i]=l[i];
    W[n]=L[n]=n;
    for (int i=0; i<kx; i++)
    {
        for (int u=0; u<=n; u++)
        {
            if (s[u]<=pw[i]) dp[i][u][0]=edge(W[u], S[u], 1e18);
            else dp[i][u][0]=edge(L[u], P[u], S[u]);
        }
        for (int j=1; j<kx; j++)
        {
            for (int u=0; u<=n; u++)
            {
                int v=dp[i][u][j-1].out;
                ll out=dp[i][v][j-1].out;
                ll cost=dp[i][u][j-1].cost+dp[i][v][j-1].cost;
                ll t=min(dp[i][u][j-1].t, dp[i][v][j-1].t-dp[i][u][j-1].cost);
                dp[i][u][j]=edge(out, cost, t);
            }
        }
    }
}

long long simulate(int x, int z) {
    ll cur=z, st=0;
    while (x!=N)
    {
        //cout<<"debug "<<x<<' '<<cur<<' '<<st<<'\n';
        while (pw[st+1]<=cur) st++;
        for (int i=kx-1; i>=0; i--) if (dp[st][x][i].t>cur) cur+=dp[st][x][i].cost, x=dp[st][x][i].out; //cout<<"here "<<i<<' '<<cur<<' '<<x<<'\n';
        //cout<<"after "<<x<<' '<<cur<<' '<<st<<'\n';
        if (cur>=S[x]) cur+=S[x], x=W[x];
        else cur+=P[x], x=L[x];
    }
	return cur;
}

# Verdict Execution time Memory Grader output
1 Correct 314 ms 678228 KB Output is correct
2 Correct 207 ms 678228 KB Output is correct
3 Correct 216 ms 678228 KB Output is correct
4 Correct 422 ms 680808 KB Output is correct
5 Correct 217 ms 678484 KB Output is correct
6 Correct 423 ms 680824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 838 ms 1205696 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 695 ms 1205524 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 695 ms 1205524 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 695 ms 1205524 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 838 ms 1205696 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -