제출 #1067678

#제출 시각아이디문제언어결과실행 시간메모리
1067678vjudge1추월 (IOI23_overtaking)C++17
65 / 100
3551 ms242300 KiB
#include "overtaking.h" #include<bits/stdc++.h> using namespace std; #pragma GCC optimize(3) #define GO(l,r) (sped*(dis[r]-dis[l])) typedef long long ll; map<ll,ll> station[1010]; map<ll,int> Pos[1010]; #define MP make_pair vector<ll> dis; map<ll,ll>memo[1010]; ll dp[1010][1010]; ll sped; int M; inline int onezsmaller(int station,ll T){ return (--Pos[station].lower_bound(T))->second; } void init(int L, int N, vector<ll> T, vector<int> W, int X, int M_, vector<int> S){ for(auto i:S)dis.push_back(i); sped=X; M=M_; for(int i=1;i<=N;i++) dp[i][0]=T[i-1]; for(int j=1;j<M;j++) {for(int i=1;i<=N;i++) dp[i][j]=dp[i][j-1]+(dis[j]-dis[j-1])*W[i-1]; vector<int>V(N); iota(V.begin(),V.end(),1); sort(V.begin(),V.end(),[j](int a,int b){ return MP(dp[a][j-1],dp[a][j])< MP(dp[b][j-1],dp[b][j]); }); ll prv=0; for(auto i:V) prv=dp[i][j]=max(dp[i][j],prv); } for(int i=1;i<=N;i++) for(int j=1;j<M;j++) if(W[i-1]>X) station[j-1][dp[i][j-1]]=max(station[j-1][dp[i][j-1]],dp[i][j]); for(int i=1;i<=N;i++) for(int j=0;j<M;j++) if(W[i-1]>X) Pos[j][dp[i][j]]++; for(int j=0;j<M;Pos[j++][-1]) if(Pos[j].size()) for(auto it=Pos[j].begin();++it!=Pos[j].end();) it->second+=prev(it)->second; for(int j=0;j<M-1;j++) station[j][-1]=0; } ll CCCALC(int STA,ll T){ int ST=STA; ll org=T; if(memo[ST][T]) return memo[ST][T]; int C=onezsmaller(ST,T); if(C==onezsmaller(M-1,GO(ST,M-1)+T)) return GO(ST,M-1)+T; int l=ST,r=M-1,res=-1; while(l<=r){ int mid=l+r>>1; if(C==onezsmaller(mid,GO(ST,mid)+T)) l=mid+1,res=mid; else r=mid-1; } assert(res>=0); T+=GO(ST,res); ST=res; return memo[STA][org]=CCCALC(res+1,(--station[res].lower_bound(T))->second); } ll arrival_time(ll Y){ return CCCALC(0,Y); }

컴파일 시 표준 에러 (stderr) 메시지

overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:24:27: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   24 |     for(int j=1;j<M;j++) {for(int i=1;i<=N;i++)
      |                           ^~~
overtaking.cpp:26:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   26 |         vector<int>V(N);
      |         ^~~~~~
overtaking.cpp: In function 'll CCCALC(int, ll)':
overtaking.cpp:58:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   58 |         int mid=l+r>>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...