제출 #843141

#제출 시각아이디문제언어결과실행 시간메모리
843141abcvuitunggio추월 (IOI23_overtaking)C++17
100 / 100
3341 ms1339180 KiB
#include "overtaking.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <ll, ll> pii; const ll INF=2e18; vector <pii> st; vector <int> le,ri; vector <pair <pii, int>> v; ll e[1001][1001],r[1001][1001],n,t[1001],w[1001],l,x,id; void gen(){ st.push_back({INF,INF}); le.push_back(-1); ri.push_back(-1); id++; } void update(int node, ll l, ll r, ll u, ll v, pii p){ if (l>v||r<u||l>r||u>v) return; if (l>=u&&r<=v){ st[node]=min(st[node],p); return; } ll mid=(l+r)>>1; if (le[node]==-1){ le[node]=id; gen(); } update(le[node],l,mid,u,v,p); if (ri[node]==-1){ ri[node]=id; gen(); } update(ri[node],mid+1,r,u,v,p); } pii get(int node, ll l, ll r, ll i){ pii p={INF,i}; while (node!=-1){ p=min(p,st[node]); ll mid=(l+r)>>1; if (mid>=i){ r=mid; node=le[node]; } else{ l=mid+1; node=ri[node]; } } return p; } void init(int L, int N, vector <ll> T, vector <int> W, int X, int m, vector <int> s){ l=L; x=X; for (int i=0;i<N;i++){ if (W[i]>x){ w[n]=W[i]; e[n][0]=t[n]=T[i]; n++; } } for (int i=1;i<m;i++){ for (int j=0;j<n;j++) v.push_back({{e[j][i-1],w[j]},j}); sort(v.begin(),v.end()); ll mx=0; for (int it=0;it<v.size();it++){ int j=v[it].second; mx=max(mx,e[j][i-1]+w[j]*(s[i]-s[i-1])); e[j][i]=mx; r[j][i-1]=min((it==v.size()-1?INF:e[v[it+1].second][i-1]),mx-x*(s[i]-s[i-1])); } v.clear(); } gen(); for (int i=m-1;i;i--){ for (int j=0;j<n;j++) v.push_back({{e[j][i],w[j]},j}); sort(v.begin(),v.end()); for (auto p:v){ int j=p.second; update(0,0,INF,e[j][i-1]+1+x*(l-s[i-1]),r[j][i-1]+x*(l-s[i-1]),{i,get(0,0,INF,e[j][i]+x*(l-s[i])).second}); } v.clear(); } } ll arrival_time(ll y){ return get(0,0,INF,y+x*l).second; }

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

overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:67:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<long long int, long long int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |         for (int it=0;it<v.size();it++){
      |                       ~~^~~~~~~~~
overtaking.cpp:71:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<long long int, long long int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |             r[j][i-1]=min((it==v.size()-1?INF:e[v[it+1].second][i-1]),mx-x*(s[i]-s[i-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...