結果
問題 | No.2100 [Cherry Alpha C] Two-way Steps |
ユーザー | a9ua1i0n |
提出日時 | 2022-10-15 00:41:59 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,394 bytes |
コンパイル時間 | 2,663 ms |
コンパイル使用メモリ | 172,420 KB |
実行使用メモリ | 20,896 KB |
最終ジャッジ日時 | 2024-06-26 18:43:22 |
合計ジャッジ時間 | 13,754 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
10,752 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 67 ms
16,000 KB |
testcase_05 | AC | 63 ms
13,840 KB |
testcase_06 | AC | 10 ms
5,376 KB |
testcase_07 | AC | 13 ms
5,760 KB |
testcase_08 | AC | 68 ms
15,744 KB |
testcase_09 | AC | 57 ms
13,936 KB |
testcase_10 | WA | - |
testcase_11 | AC | 48 ms
12,712 KB |
testcase_12 | AC | 39 ms
10,624 KB |
testcase_13 | AC | 34 ms
11,136 KB |
testcase_14 | AC | 42 ms
10,752 KB |
testcase_15 | AC | 40 ms
11,580 KB |
testcase_16 | AC | 47 ms
11,648 KB |
testcase_17 | AC | 22 ms
8,960 KB |
testcase_18 | AC | 37 ms
11,392 KB |
testcase_19 | AC | 86 ms
18,020 KB |
testcase_20 | AC | 17 ms
6,656 KB |
testcase_21 | AC | 36 ms
10,240 KB |
testcase_22 | AC | 44 ms
11,264 KB |
testcase_23 | AC | 60 ms
14,720 KB |
testcase_24 | AC | 99 ms
19,420 KB |
testcase_25 | AC | 104 ms
19,544 KB |
testcase_26 | AC | 98 ms
19,536 KB |
testcase_27 | AC | 93 ms
19,428 KB |
testcase_28 | AC | 99 ms
19,540 KB |
testcase_29 | AC | 90 ms
19,404 KB |
testcase_30 | AC | 94 ms
19,544 KB |
testcase_31 | AC | 90 ms
19,528 KB |
testcase_32 | AC | 92 ms
19,408 KB |
testcase_33 | AC | 95 ms
19,424 KB |
testcase_34 | AC | 110 ms
15,360 KB |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 147 ms
15,744 KB |
testcase_39 | TLE | - |
testcase_40 | TLE | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
ソースコード
#if !__INCLUDE_LEVEL__ #include __FILE__ ll dijkstra(int start, int end, vector<vector<edge<ll>>>& graph) { vector<ll> dist(graph.size(), 1e15); using node = pair<ll, pair<int, bool>>; priority_queue<node, vector<node>, greater<node>> pque; pque.push(node(0, pair<int, bool>(start, false))); dist[start] = 0; while (!pque.empty()) { auto cn = pque.top(); ll cost = cn.first; ll index = cn.second.first; bool up = cn.second.second; pque.pop(); if (dist[index] != cost) { continue; } for (auto nn: graph[index]) { if (up && nn.up) { continue; } if (dist[nn.to] <= cost + nn.cost) { continue; } dist[nn.to] = cost + nn.cost; pque.push(node(cost + nn.cost, pair<int, bool>(nn.to, nn.up))); } } cerr << dist[end] << "\n"; return dist[end] <= 0 ? -dist[end] : -1; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N, M; cin >> N >> M; vector<ll> H(N); REP(i, N) cin >> H[i]; vector<vector<edge<ll>>> cher(N), zelc(N); REP(i, M) { ll x, y; cin >> x >> y; x--; y--; if (H[x] > H[y]) { cher[x].push_back(edge<ll>(y, 0, false)); zelc[y].push_back(edge<ll>(x, -(H[x] - H[y]), true)); } else { cher[x].push_back(edge<ll>(y, -(H[y] - H[x]), true)); zelc[y].push_back(edge<ll>(x, 0, false)); } } cout << dijkstra(0, N - 1, cher) << "\n"; cout << dijkstra(N - 1, 0, zelc) << "\n"; return 0; } //====================temp==================== #else #include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define REPITR(itr, ARRAY) \ for (auto itr = (ARRAY).begin(); itr != (ARRAY).end(); ++itr) #define RREPITR(itr, ARRAY) \ for (auto itr = (ARRAY).rbegin(); itr != (ARRAY).rend(); ++itr) #define ALL(n) (n).begin(), (n).end() using ll = long long; using ull = unsigned long long; //#define int long long template<typename T> struct edge { int to; T cost; bool up; edge() {} edge(int to, T cost, bool up): to(to), cost(cost), up(up) {} }; #endif