結果

問題 No.1812 Uribo Road
ユーザー trineutrontrineutron
提出日時 2022-01-14 23:10:34
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,414 bytes
コンパイル時間 3,923 ms
コンパイル使用メモリ 265,532 KB
実行使用メモリ 175,120 KB
最終ジャッジ日時 2024-04-30 17:04:16
合計ジャッジ時間 10,444 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,820 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 32 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 23 ms
6,944 KB
testcase_09 AC 49 ms
6,944 KB
testcase_10 AC 16 ms
6,944 KB
testcase_11 AC 10 ms
6,940 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using edge = tuple<int, int, int>;

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<bool> must(m);
    for (int i = 0; i < k; i++)
    {
        int r;
        cin >> r;
        r--;
        must.at(r) = true;
    }
    const int s = 1 << k;
    vector<edge> to[n];
    int idx = 0;
    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        if (must.at(i))
        {
            idx++;
            to[a].emplace_back(b, c, idx);
            to[b].emplace_back(a, c, idx);
        }
        to[a].emplace_back(b, c, 0);
        to[b].emplace_back(a, c, 0);
    }
    vector dist(n, vector<int>(s, 2e9));
    priority_queue<edge, vector<edge>, greater<edge>> q;
    q.emplace(0, 0, 0);
    while (not q.empty())
    {
        auto [d0, v, seen] = q.top();
        q.pop();
        if (d0 >= dist[v][seen])
        {
            continue;
        }
        dist[v][seen] = d0;
        for (auto &&[c, d_edge, r_idx] : to[v])
        {
            int seen_new = seen;
            if (r_idx)
            {
                seen_new |= 1 << (r_idx - 1);
            }
            if (d0 + d_edge >= dist[c][seen_new])
            {
                continue;
            }
            q.emplace(d0 + d_edge, c, seen_new);
        }
    }
    cout << dist.back().back() << endl;
    return 0;
}
0