이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |