Submission #961464

#TimeUsernameProblemLanguageResultExecution timeMemory
961464WarinchaiDungeons Game (IOI21_dungeons)C++17
26 / 100
291 ms231936 KiB
#include "dungeons.h" #include<bits/stdc++.h> using namespace std; int lift[26][400005]; long long mn[26][400005]; long long dis[26][400005]; 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<=25;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]); } } /*for(int i=0;i<=n;i++){ for(int j=0;j<3;j++){ cerr<<i<<" "<<j<<":"<<dis[j][i]<<" "<<lift[j][i]<<"\n"; } cerr<<"\n"; }*/ //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<<"new:"<<x<<" "<<pow<<"\n"; for(int i=25;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"*/; } //cerr<<x<<" "<<pow<<"\n\n"; if(x==N)break; pow+=P[x]; x=L[x]; } ///cerr<<x<<" "<<pow<<"\n"; //cerr<<"\n"; return pow; }

Compilation message (stderr)

dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:43:15: warning: unused variable 'c' [-Wunused-variable]
   43 |     long long c=0,lv=0;
      |               ^
dungeons.cpp:43:19: warning: unused variable 'lv' [-Wunused-variable]
   43 |     long long c=0,lv=0;
      |                   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...