제출 #623277

#제출 시각아이디문제언어결과실행 시간메모리
623277Koosha_mv던전 (IOI21_dungeons)C++17
0 / 100
2195 ms724288 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; #define dbgv(v) cout<<#v<<" = "; f(i,0,int(v.size())) cout<<v[i]<<" "; cout<<endl #define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl #define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define all(v) v.begin(),v.end() #define bit(n,k) (((n)>>(k))&1) #define Add(x,y) x=(x+y)%mod #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first const int N=50500,lg=26; const ll inf=1e18+99; int n; int par[lg/2][N][lg]; ll Min[lg/2][N][lg]; ll prt[lg/2][N][lg]; vector<int> s,p,w,t; void init(int _n,vector<int> _s,vector<int> _p,vector<int> _w,vector<int> _t) { n=_n; s=_s,p=_p,w=_w,t=_t; s.pb((1<<(lg-1))); w.pb(-1); t.pb(-1); p.pb(-1); f(l,0,lg/2){ f(i,0,n+1){ if(s[i]<=(1<<(l<<1))){ par[l][i][0]=w[i]; prt[l][i][0]=s[i]; Min[l][i][0]=inf; } else{ par[l][i][0]=t[i]; prt[l][i][0]=p[i]; Min[l][i][0]=(i==n ? 0 : s[i]); } } f(j,1,lg){ f(i,0,n+1){ int nxt=par[l][i][j-1]; par[l][i][j]=par[l][nxt][j-1]; prt[l][i][j]=prt[l][i][j-1]+prt[l][nxt][j-1]; Min[l][i][j]=min(Min[l][i][j-1],Min[l][nxt][j-1]-prt[l][i][j-1]); } } } } ll simulate(int pos,int _val){ int l=0; ll val=_val; while(1){ while((1<<(2*(l+1)))<=val && l+1<lg/2) l++; //cout<<pos<<" "<<val<<" -> "<<l<<endl; f_(i,lg-1,0){ if(Min[l][pos][i]>=val){ val+=prt[l][pos][i]; pos=par[l][pos][i]; } } if(pos==n) break ; //cout<<"posval "<<pos<<" "<<val<<endl; val+=s[pos]; pos=w[pos]; } return val; } /* 3 1 2 6 9 3 1 2 2 2 3 1 0 1 0 1 */
#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...