Submission #961382

# Submission time Handle Problem Language Result Execution time Memory
961382 2024-04-12T02:47:59 Z Warinchai Dungeons Game (IOI21_dungeons) C++17
0 / 100
158 ms 80724 KB
#include "dungeons.h"
#include<bits/stdc++.h>
using namespace std;
int lift[17][50005];
long long mn[17][50005];
long long dis[17][50005];
long long inf=1e18+7;
int N;
vector<int>W;
vector<int>S;
vector<int>L;
vector<int>P;
void init(int n,vector<int> s,vector<int> p,vector<int> w,vector<int> l) {
    N=n;
    S=s;
    W=w;
    L=l;
    P=p;
    for(int j=0;j<n;j++){
        lift[0][j]=w[j],mn[0][j]=s[j],dis[0][j]=p[j];
    }
    lift[0][n]=n;
    mn[0][n]=inf;
    for(int j=1;j<=16;j++){
        for(int k=0;k<=n;k++){
            lift[j][k]=lift[j-1][lift[j-1][k]];
            dis[j][k]=dis[j-1][k]+dis[j-1][lift[j-1][k]];
            mn[j][k]=max(mn[j-1][k],mn[j-1][lift[j-1][k]]-dis[j-1][k]);
        }
    }
    //cerr<<"work\n";
	return;
}

long long simulate(int x, int z) {
    //cerr<<"work\n";
    long long c=0,lv=0;
    long long pow=z;
    /*while(x>(1<<c)){
        lv=c;
        c++;
    }*/
    //cerr<<x<<"\n";
    //cerr<<lv<<"\n";
    while(1){
        //cerr<<x<<" "<<pow<<"\n";
        for(int i=15;i>=0;i--){
            //cerr<<i<<" "<<lv<<" "<<x<<"\n";
            if(pow>=mn[i][x])pow+=dis[i][x],x=lift[i][x];
        }
        //cerr<<x<<" "<<pow<<"\n\n";
        if(x==N)break;
        pow+=P[x];
        x=L[x];
    }
	return pow;
}

Compilation message

dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:37:15: warning: unused variable 'c' [-Wunused-variable]
   37 |     long long c=0,lv=0;
      |               ^
dungeons.cpp:37:19: warning: unused variable 'lv' [-Wunused-variable]
   37 |     long long c=0,lv=0;
      |                   ^~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 16732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 16844 KB Output is correct
2 Runtime error 158 ms 80724 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 16984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 16984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 16984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 16844 KB Output is correct
2 Runtime error 158 ms 80724 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -