Submission #00200


ソースコード

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
#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;
cin>>n>>m>>x;
int min_cost[n+1];
vector<P>node[n+1];
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;
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:57:52
言語 C++11
状態 Runtime Error
得点 0
ソースコード長 935 Byte
最大実行時間 85 ms
最大メモリ使用量 6508 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
1.in AC 18 ms 480 KB
1
2.in AC 15 ms 460 KB
1
3.in AC 18 ms 568 KB
1
4.in AC 31 ms 1000 KB
1
5.in AC 85 ms 6508 KB
1
6.in RE 66 ms 388 KB
1