Submission #00196
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #include<iostream> #include<queue> #include<vector> #define INF 1<<30 using namespace std; typedef pair< int , int >P; int main(){ int n,m,x; int a,b,c; int min_cost[100005]; vector<P>node[100005]; cin>>n>>m>>x; for ( int i=0;i<=n;i++){ min_cost[i]=INF; } for ( int i=0;i<m;i++){ cin>>a>>b>>c; node[a].push_back(P(b,c)); node[b].push_back(P(a,c)); } priority_queue<P,vector<P>,greater<P> >pq; pq.push(P(0,1)); while (!pq.empty()){ P now=pq.top(); pq.pop(); int cost=now.first; int pos=now.second; if (cost>x) break ; for ( int i=0;i<node[pos].size();i++){ int next=node[pos][i].first; int ncost=node[pos][i].second+cost; if (ncost<min_cost[next]){ min_cost[next]=ncost; pq.push(P(ncost,next)); } } } if (min_cost[n]==INF||min_cost[n]*2>x){ cout<< "sleep" <<endl; } else { cout<<min_cost[n]*2<<endl; } return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0003 - 眠れる獅子の肝試し |
ユーザー名 | ei1630 |
投稿日時 | 2017-05-05 22:52:22 |
言語 | C++11 |
状態 | Runtime Error |
得点 | 0 |
ソースコード長 | 963 Byte |
最大実行時間 | 134 ms |
最大メモリ使用量 | 6472 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 100 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
1.in | AC | 19 ms | 2784 KB |
1
|
2.in | AC | 22 ms | 2724 KB |
1
|
3.in | AC | 24 ms | 2792 KB |
1
|
4.in | AC | 30 ms | 3204 KB |
1
|
5.in | AC | 79 ms | 6472 KB |
1
|
6.in | RE | 134 ms | 3296 KB |
1
|