Submission #1016618

#TimeUsernameProblemLanguageResultExecution timeMemory
1016618JakobZorzDungeons Game (IOI21_dungeons)C++17
11 / 100
7059 ms299452 KiB
#include"dungeons.h" #include<vector> typedef long long ll; using namespace std; int n; struct Dungeon{ vector<int>nxt1; // win vector<int>nxt2; // lose vector<ll>st1; // strength vector<ll>st2; // gain on losing ll thres=0; Dungeon(int n):nxt1(n),nxt2(n),st1(n),st2(n){} Dungeon()=default; // simulate until it either reaches n-th node, wins, or strength>=thres pair<int,ll>simulate(int x,ll st){ while(st<thres&&x!=n){ if(st>=st1[x]){ st+=st1[x]; x=nxt1[x]; break; } st+=st2[x]; x=nxt2[x]; } return{x,st}; } }; Dungeon dun[30]; void init(int N,vector<int>s,vector<int>p,vector<int>w,vector<int>l){ n=N; for(int pw=0;pw<30;pw++){ dun[pw]=Dungeon(n); dun[pw].thres=2LL<<pw; for(int i=0;i<n;i++){ if(s[i]<=1<<pw){ dun[pw].nxt1[i]=0; dun[pw].nxt2[i]=w[i]; dun[pw].st1[i]=1e18; dun[pw].st2[i]=s[i]; }else if(s[i]>=2<<pw){ dun[pw].nxt1[i]=0; dun[pw].nxt2[i]=l[i]; dun[pw].st1[i]=1e18; dun[pw].st2[i]=p[i]; }else{ dun[pw].nxt1[i]=w[i]; dun[pw].nxt2[i]=l[i]; dun[pw].st1[i]=s[i]; dun[pw].st2[i]=p[i]; } } } dun[29].thres=1e18; } ll simulate(int x,int z){ ll st=z; for(int p=0;p<30;p++){ while(x!=n&&st<2LL<<p){ auto r=dun[p].simulate(x,st); x=r.first; st=r.second; } } return st; }
#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...