結果
問題 | No.2387 Yokan Factory |
ユーザー | 憩いの場 |
提出日時 | 2023-07-21 22:38:50 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 421 ms / 5,000 ms |
コード長 | 1,962 bytes |
コンパイル時間 | 2,274 ms |
コンパイル使用メモリ | 83,188 KB |
実行使用メモリ | 9,660 KB |
最終ジャッジ日時 | 2023-10-21 22:39:29 |
合計ジャッジ時間 | 6,562 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | AC | 2 ms
4,348 KB |
testcase_05 | AC | 2 ms
4,348 KB |
testcase_06 | AC | 2 ms
4,348 KB |
testcase_07 | AC | 1 ms
4,348 KB |
testcase_08 | AC | 1 ms
4,348 KB |
testcase_09 | AC | 2 ms
4,348 KB |
testcase_10 | AC | 1 ms
4,348 KB |
testcase_11 | AC | 1 ms
4,348 KB |
testcase_12 | AC | 2 ms
4,348 KB |
testcase_13 | AC | 2 ms
4,348 KB |
testcase_14 | AC | 2 ms
4,348 KB |
testcase_15 | AC | 242 ms
9,660 KB |
testcase_16 | AC | 146 ms
8,500 KB |
testcase_17 | AC | 374 ms
9,428 KB |
testcase_18 | AC | 273 ms
8,996 KB |
testcase_19 | AC | 256 ms
7,164 KB |
testcase_20 | AC | 226 ms
6,812 KB |
testcase_21 | AC | 421 ms
8,600 KB |
testcase_22 | AC | 199 ms
6,532 KB |
testcase_23 | AC | 283 ms
7,236 KB |
testcase_24 | AC | 157 ms
6,752 KB |
testcase_25 | AC | 164 ms
5,692 KB |
testcase_26 | AC | 312 ms
7,700 KB |
testcase_27 | AC | 391 ms
8,440 KB |
testcase_28 | AC | 4 ms
4,348 KB |
testcase_29 | AC | 4 ms
4,348 KB |
testcase_30 | AC | 4 ms
4,348 KB |
testcase_31 | AC | 3 ms
4,348 KB |
testcase_32 | AC | 3 ms
4,348 KB |
testcase_33 | AC | 2 ms
4,348 KB |
testcase_34 | AC | 5 ms
4,348 KB |
testcase_35 | AC | 4 ms
4,348 KB |
testcase_36 | AC | 2 ms
4,348 KB |
testcase_37 | AC | 2 ms
4,348 KB |
ソースコード
#include<iostream> #include<vector> #include<queue> using namespace std; class Node { public : int id; int cost; int width; Node() = default; Node( int id, int cost, int width ) : id( id ), cost( cost ), width( width ) {}; bool operator < ( const Node &node ) const { return this->cost < node.cost; } }; int main( void ) { int N, M; long long X; cin >> N >> M >> X; vector<vector<Node>> Graph( N + 1 ); int u, v, a, b; int max_width = 0; for( int i = 0; i < M; i++ ) { cin >> u >> v >> a >> b; max_width = max( max_width, b ); Graph[u].push_back( Node( v, a, b ) ); Graph[v].push_back( Node( u, a, b ) ); } int left = 0, right = max_width + 1; int mid; vector<long long> shortest( N + 1 ); while( left < right ) { mid = ( left + right ) / 2 + 1; shortest.assign( N + 1, -1 ); priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q; shortest[1] = 0; q.push( make_pair( 0, 1 ) ); pair<long long, int> cur; while( !q.empty() ) { cur = q.top(), q.pop(); if( cur.first > shortest[cur.second] ) continue; for( Node next : Graph[cur.second] ) { if( next.width >= mid && ( shortest[next.id] == -1 || shortest[next.id] > shortest[cur.second] + next.cost ) ) { shortest[next.id] = shortest[cur.second] + next.cost; q.push( make_pair( shortest[next.id], next.id ) ); } } } if( shortest[N] == -1 || shortest[N] > X ) { right = mid - 1; } else { left = mid; } } if( left == 0 ) { cout << -1 << endl; } else { cout << left << endl; } return 0; }