Submission #00073
ソースコード
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | #include <iostream> #include <string> #include <cstdio> #include <vector> #include <algorithm> #include <queue> #include <utility> #define INF (1ll << 60ll) using namespace std; typedef long long ll; typedef pair<ll, ll> pll; ll n, m, q; ll y, d, k; string s; ll a, b, c; ll x[100005]; ll min_cost[100005]; priority_queue<pll, vector<pll>, greater<pll> >p_que; vector<pll> graph[100005]; vector<ll> Y; vector<ll> D; vector<ll> K; void dijkstra( void ) { while (!p_que.empty()) { pll now = p_que.top(); p_que.pop(); ll cost = now.first; ll pos = now.second; for (ll i = 0; i < graph[pos].size(); i++) { ll npos = graph[pos][i].second; ll ncos = cost + graph[pos][i].first; if (min_cost[npos] > ncos) { min_cost[npos] = ncos; p_que.push(pll(ncos, npos)); } } } for (ll i = 0; i < n; i++) { if (s[i] == 'Y' ) { Y.push_back(min_cost[i]); } else if (s[i] == 'D' ) { D.push_back(min_cost[i]); } else if (s[i] == 'K' ) { K.push_back(min_cost[i]); } } sort(Y.begin(), Y.end()); sort(D.begin(), D.end()); sort(K.begin(), K.end()); return ; } int main() { Y.push_back(INF); D.push_back(INF); K.push_back(INF); ll start; cin >> n >> m >> q; cin >> y >> d >> k; cin >> s; for (ll i = 0; i < n; i++) { min_cost[i] = INF; } for (ll i = 0; i < n; i++) { if (s[i] == 'D' ) { p_que.push(pll(0, i)); min_cost[i] = 0; } } for (ll i = 0; i < m; i++) { cin >> a >> b >> c; a--; b--; graph[a].push_back(pll(c, b)); graph[b].push_back(pll(c, a)); } for (ll i = 0; i < q; i++) { cin >> x[i]; } dijkstra(); for (ll i = 0; i < q; i++) { ll yy = (upper_bound(Y.begin(), Y.end(), x[i]) - Y.begin()) * y; ll dd = (upper_bound(D.begin(), D.end(), x[i]) - D.begin()) * d; ll kk = (upper_bound(K.begin(), K.end(), x[i]) - K.begin()) * k; cout << yy + dd + kk << endl; } return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0004 - 雛ちゃん王国の改装 |
ユーザー名 | ei1710 |
投稿日時 | 2019-02-28 16:56:54 |
言語 | C++14 |
状態 | Runtime Error |
得点 | 0 |
ソースコード長 | 1976 Byte |
最大実行時間 | 385 ms |
最大メモリ使用量 | 15812 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 6 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
sample01.in | AC | 20 ms | 2908 KB |
1
|
sample02.in | AC | 21 ms | 2704 KB |
1
|
test01.in | RE | 385 ms | 4560 KB |
1
|
test02.in | RE | 37 ms | 3564 KB |
1
|
test03.in | RE | 48 ms | 4656 KB |
1
|
test04.in | RE | 39 ms | 3728 KB |
1
|
test05.in | RE | 52 ms | 4752 KB |
1
|
test06.in | RE | 43 ms | 3748 KB |
1
|
test07.in | RE | 54 ms | 4896 KB |
1
|
test08.in | RE | 56 ms | 5012 KB |
1
|
test09.in | RE | 40 ms | 3880 KB |
1
|
test10.in | RE | 65 ms | 5016 KB |
1
|
test11.in | RE | 47 ms | 3812 KB |
1
|
test12.in | RE | 61 ms | 5128 KB |
1
|
test13.in | RE | 40 ms | 3984 KB |
1
|
test14.in | RE | 30 ms | 2932 KB |
1
|
test15.in | RE | 42 ms | 4008 KB |
1
|
test16.in | RE | 40 ms | 3392 KB |
1
|
test17.in | RE | 49 ms | 4124 KB |
1
|
test18.in | RE | 36 ms | 3444 KB |
1
|
test19.in | RE | 44 ms | 4052 KB |
1
|
test20.in | RE | 45 ms | 4204 KB |
1
|
test21.in | RE | 34 ms | 3396 KB |
1
|
test22.in | RE | 44 ms | 4508 KB |
1
|
test23.in | RE | 33 ms | 3376 KB |
1
|
test24.in | RE | 52 ms | 4348 KB |
1
|
test25.in | RE | 36 ms | 3280 KB |
1
|
test26.in | RE | 51 ms | 4456 KB |
1
|
test27.in | RE | 33 ms | 3316 KB |
1
|
test28.in | RE | 57 ms | 4680 KB |
1
|
test29.in | RE | 39 ms | 3348 KB |
1
|
test30.in | RE | 49 ms | 4676 KB |
1
|
test31.in | RE | 139 ms | 13888 KB |
1
|
test32.in | RE | 193 ms | 15812 KB |
1
|
test33.in | RE | 116 ms | 11548 KB |
1
|
test34.in | RE | 128 ms | 12396 KB |
1
|
test35.in | RE | 128 ms | 12256 KB |
1
|
test36.in | RE | 121 ms | 11284 KB |
1
|
test37.in | RE | 132 ms | 12280 KB |
1
|
test38.in | RE | 150 ms | 14264 KB |
1
|
test39.in | RE | 130 ms | 12856 KB |
1
|
test40.in | RE | 131 ms | 12004 KB |
1
|