結果
問題 |
No.1 道のショートカット
|
ユーザー |
![]() |
提出日時 | 2018-02-28 15:55:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,700 bytes |
コンパイル時間 | 577 ms |
コンパイル使用メモリ | 75,960 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-08 04:59:36 |
合計ジャッジ時間 | 1,548 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 WA * 18 |
ソースコード
#include <iostream> #include <queue> #include <map> using namespace std; struct Info{ int from,to,cost,time; }; struct Dik{ int vertex; int cost,time; bool operator<(const Dik &other)const{ return cost>other.cost; } }; int main(){ int N,current,ver; cin >> N >> current; cin >> ver; Info info[1500]; for(int i=0 ; i<ver ; i++ ) cin >> info[i].from; for(int i=0 ; i<ver ; i++ ) cin >> info[i].to; for(int i=0 ; i<ver ; i++ ) cin >> info[i].cost; for(int i=0 ; i<ver ; i++ ) cin >> info[i].time; priority_queue<Dik> circle; Dik now;now.vertex=1; now.cost=now.time=0; circle.push(now); map <int,bool> past; int min=1000000000; while(circle.size()!=0){ now=circle.top();circle.pop(); if(now.cost>current)continue; if(now.vertex==N) if(min>now.time)min=now.time; if(past[now.vertex])continue; past[now.vertex]=true; Dik next; for(int i=0 ; i<ver ; i++ ){ if(info[i].from==now.vertex){ next.vertex=info[i].to; next.cost=now.cost+info[i].cost; next.time=now.time+info[i].time; circle.push(next); } } } if(min==1000000000) cout<<-1<<endl; else cout << min << endl; return 0; }