結果
問題 |
No.1 道のショートカット
|
ユーザー |
![]() |
提出日時 | 2018-02-28 16:05:06 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,627 bytes |
コンパイル時間 | 535 ms |
コンパイル使用メモリ | 71,640 KB |
実行使用メモリ | 556,556 KB |
最終ジャッジ日時 | 2024-07-08 04:59:43 |
合計ジャッジ時間 | 7,113 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 MLE * 1 -- * 32 |
ソースコード
#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; 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.front();circle.pop(); if(now.cost>current)continue; if(now.vertex==N){ if(min>now.time)min=now.time; } 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; }