#if !__INCLUDE_LEVEL__ #include __FILE__ const ll INF = numeric_limits::max()/3; void solve(){ ll N, M, X; cin >> N >> M >> X; vvc> graph(N); rep(i, M){ ll a, b, c, d; cin >> a >> b >> c >> d; a--; b--; graph[a].eb(b, c, d); graph[b].eb(a, c, d); } auto dijkstra = [&](ll s, ll b){ priority_queue, vector>, greater>> que; vc dists(N, INF); dists[s] = 0; que.emplace(dists[s], 0); while(!que.empty()) { ll cost, v; tie(cost, v) = que.top(); que.pop(); if(dists[v] < cost) continue; for(auto [nv, ncost, nb] : graph[v]) { if(nb < b) continue; auto next_cost = cost + ncost; if(dists[nv] <= next_cost) continue; dists[nv] = next_cost; que.emplace(dists[nv], nv); } } return dists[N-1]; }; ll d = dijkstra(0, 0); if(d > X){ print(-1); return; } ll l=0, r=INF; while(l+1 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define ll long long #define OVERLOAD(e1,e2,e3,e4,NAME,...) NAME #define _rep1(i,n) for(long long i=0;i inline void print(const pair& p) {cout << p.first << " " << p.second << endl;} template inline void print(const T& x) {cout << x << "\n";} template inline void print(const vector>& v) {for (auto&& p : v) print(p);} void yes(bool a){cout<<(a?"yes":"no")< T SUM(vc As){T ret=0; for(T a: As) ret += a; return ret;} // #pragma endregion #endif