Submission #00181


ソースコード

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
45
46
47
48
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<map>
#include<functional>
using namespace std;
#define INF 1000000009
struct edge { int to, cost; };
vector<edge>G[1019810];
typedef pair<int, int>P;
int d[1019810];
int n, m, xa;
void dijk(int s) {
priority_queue<P, vector<P>, greater<P>>Q;
fill(d, d + n, INF);
d[s] = 0;
Q.push(P(0, s));
while (Q.size()) {
P p = Q.top();
Q.pop();
int v = p.second;
if (d[v] < p.first)continue;
for (int i = 0; i < G[v].size(); i++) {
edge e = G[v][i];
if (d[e.to] > d[v] + e.cost) {
d[e.to] = d[v] + e.cost;
Q.push(P(d[e.to], e.to));
}
}
}
return;
}
int main() {
cin >> n >> m >> xa;
for (int i = 0; i < m; i++) {
int s, t, x;
cin >> s >> t >> x;
G[s - 1].push_back({ t - 1,x });
G[t - 1].push_back({ s - 1,x });
}
dijk(0);
if (d[n - 1] * 2 > xa)cout << "sleep" << endl;
else cout << 2 * d[n - 1] << endl;
return 0;
}

ステータス

項目 データ
問題 0003 - 眠れる獅子の肝試し
ユーザー名 ryotori
投稿日時 2017-05-05 22:17:48
言語 C++11
状態 Accepted
得点 100
ソースコード長 984 Byte
最大実行時間 555 ms
最大メモリ使用量 55372 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
1.in AC 28 ms 26336 KB
1
2.in AC 21 ms 26452 KB
1
3.in AC 20 ms 26440 KB
1
4.in AC 32 ms 26644 KB
1
5.in AC 82 ms 29956 KB
1
6.in AC 555 ms 55372 KB
1