Submission #00195


ソースコード

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[1000005];
vector<P>node[1000005];
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:51:51
言語 C++11
状態 Runtime Error
得点 0
ソースコード長 965 Byte
最大実行時間 112 ms
最大メモリ使用量 592 KB

セット

セット 得点 Cases
1 ALL 0 / 100 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
1.in RE 112 ms 480 KB
1
2.in RE 25 ms 472 KB
1
3.in RE 29 ms 592 KB
1
4.in RE 28 ms 584 KB
1
5.in RE 26 ms 576 KB
1
6.in RE 30 ms 560 KB
1