結果
| 問題 | No.2387 Yokan Factory |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-23 17:48:49 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 427 ms / 5,000 ms |
| + 735µs | |
| コード長 | 4,980 bytes |
| 記録 | |
| コンパイル時間 | 2,772 ms |
| コンパイル使用メモリ | 350,312 KB |
| 実行使用メモリ | 17,840 KB |
| 最終ジャッジ日時 | 2026-10-23 17:48:59 |
| 合計ジャッジ時間 | 9,223 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
/*
#include<kyopro/master>
void self::main(){
LL(N,M,T);
VV(M,u,v,a,b);dec(u,v);
pp(binary_search_last_true(-1,1e9+1,[&](ll X){
Graph<ll>g(N);
fo(i,M){
if(X<=b[i]){
g.add_edge(u[i],v[i],a[i]);
g.add_edge(v[i],u[i],a[i]);
}
}
return g.dijkstra_dist_enumerate(0)[N-1]<=T;
}));
}
*/
#include<bits/stdc++.h>
using namespace std;
namespace self{void main();void sub();template<ostream&o>void pp(const auto&...a);void epp(const auto&...a);}
int main(){cin.tie(nullptr)->sync_with_stdio(0);cout<<fixed<<setprecision(15);self::main();}
#define eb emplace_back
#define RD(T,...) T __VA_ARGS__;lin(__VA_ARGS__)
#define LL(...) RD(ll,__VA_ARGS__)
#define RDVV(T,n,...) vec<T>__VA_ARGS__;fe(refs(__VA_ARGS__),e)e.get().resizes(n);vin(__VA_ARGS__)
#define VV(n,...) RDVV(ll,n,__VA_ARGS__)
#define fo(i,...) for(auto[i,i##stop,i##step]=for_range<ll>(0,__VA_ARGS__);i<i##stop;i+=i##step)
#define fe(a,e,...) for(auto&&__VA_OPT__([)e __VA_OPT__(,__VA_ARGS__]):a)
namespace self{
using ll=long long;
constexpr auto refs(auto&...a){return array{ref(a)...};}
template<class T>constexpr auto for_range(T s,T b){T a=0;if(s)swap(a,b);return array{a-s,b,1-s*2};}
void lin(auto&...a){(cin>>...>>a);}
void vin(auto&...a){fo(i,(a.size()&...))(cin>>...>>a[i]);}
constexpr ll size10(auto x){x|=1;ll r=0;while(x>0)x/=10,++r;return r;}
template<class T>constexpr ll maxsize10(){return size10(numeric_limits<T>::max());}
bool amin(auto&a,const auto&b){return b<a?a=b,1:0;}
ll binary_search_last_true(ll l,ll r,auto&&f){while(l+1<r)(f((l+r)/2)?l:r)=(l+r)/2;return l;}
template<class A,class B=A>struct pair{
A a;B b;
pair()=default;
pair(A a,B b):a(a),b(b){}
auto operator<=>(const pair&)const=default;
};
template<bool is_negative=false>struct infinity{
template<integral T>static constexpr T ones(size_t n){return n?ones<T>(n-1)*10+1:0;}
template<integral T>constexpr operator T()const{return ones<T>(maxsize10<T>())*(1-is_negative*2);}
};
constexpr infinity oo;
void dec(auto&...a){((--a),...);}
template<class...A>using pack_back_t=tuple_element_t<sizeof...(A)-1,tuple<A...>>;
}
namespace self{
template<class V>constexpr int depth=0;
template<class T>struct core_t_helper{using type=T;};
template<class T>using core_t=core_t_helper<T>::type;
template<class V>struct vec;
template<int D,class T>struct hvec_helper{using type=vec<typename hvec_helper<D-1,T>::type>;};
template<class T>struct hvec_helper<0,T>{using type=T;};
template<int D,class T>using hvec=hvec_helper<D,T>::type;
template<class V>struct vec:vector<V>{
static constexpr int D=depth<V>+1;
using C=core_t<V>;
using vector<V>::vector;
void resizes(const auto&...a){if constexpr(sizeof...(a)==D)*this=make(a...,C{});else{ }}
static auto make(ll n,const auto&...a){
if constexpr(sizeof...(a)==1)return vec<C>(n,array{a...}[0]);
else { }
}
vec&operator--(){fe(*this,e)--e;return*this;}
ll size()const{return vector<V>::size();}
auto&emplace_back(auto&&...a){vector<V>::emplace_back(std::forward<decltype(a)>(a)...);return*this;}
};
template<class...A>requires(sizeof...(A)>=2)vec(const A&...a)->vec<hvec<sizeof...(A)-2,pack_back_t<A...>>>;
}
namespace self{
template<class T,class F>struct priority_queue:std::priority_queue<T,vector<T>,F>{
priority_queue()=default;
priority_queue(const initializer_list<T>&a){fe(a,e)this->emplace(e);}
ll size()const{return std::priority_queue<T,vector<T>,F>::size();}
T pop(){T r=this->top();std::priority_queue<T,vector<T>,F>::pop();return r;}
};
template<class T>using min_heap=priority_queue<T,greater<T>>;
}
namespace self{
template<class WT>struct edge{
int from,to;
WT wt;
int id;
edge()=default;
edge(int from,int to,WT wt=1,int id=-1):from(from),to(to),wt(wt),id(id){}
auto operator<=>(const edge&e)const{return wt<=>e.wt;}
};
}
namespace self{
template<class WT>class Graph{
public:
ll n_;
vec<vec<edge<WT>>>edges_;
Graph()=default;
Graph(ll n):n_(n),edges_(n){}
void add_edge(ll a,auto&&...b){edges_[a].eb(a,std::forward<decltype(b)>(b)...);}
auto dijkstra_dist_enumerate(int s)const{
vec<WT>dist(n_,oo);
dist[s]=WT{};
vec<bool>used(n_);
min_heap<pair<WT,edge<WT>>>q{{WT{},{-1,s,WT{},-1}}};
while(q.size()){
auto[du,pu]=q.pop();
auto u=pu.to;
if(dist[u]<du)continue;
if(used[u])continue;
used[u]=1;
fe(edges_[u],e){
if(amin(dist[e.to],dist[u]+e.wt)){
assert(e.wt>=WT{});
assert(!used[e.to]);
q.emplace(dist[e.to],e);
}
}
}
return dist;
}
};
}
template<ostream&o=cout>void self::pp(const auto&...a){const char*c="";((o<<c<<a,c=" "),...);o<<'\n';}
void self::main(){
LL(N,M,T);
VV(M,u,v,a,b);dec(u,v);
pp(binary_search_last_true(-1,1e9+1,[&](ll X){
Graph<ll>g(N);
fo(i,M){
if(X<=b[i]){
g.add_edge(u[i],v[i],a[i]);
g.add_edge(v[i],u[i],a[i]);
}
}
return g.dijkstra_dist_enumerate(0)[N-1]<=T;
}));
}