結果

問題 No.1812 Uribo Road
ユーザー trineutrontrineutron
提出日時 2022-01-14 22:34:02
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,509 bytes
コンパイル時間 3,260 ms
コンパイル使用メモリ 258,564 KB
実行使用メモリ 813,600 KB
最終ジャッジ日時 2024-04-30 16:03:58
合計ジャッジ時間 5,186 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 27 ms
7,168 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 42 ms
9,472 KB
testcase_09 AC 91 ms
14,304 KB
testcase_10 AC 35 ms
8,748 KB
testcase_11 AC 15 ms
6,940 KB
testcase_12 MLE -
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 = pair<int, int>;
using graph = vector<edge>;

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;
    graph to[n * s];
    int idx = 0;
    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        for (int j = 0; j < s; j++)
        {
            if (must.at(i))
            {
                to[a * s + j].emplace_back(b * s + (j | (1 << idx)), c);
                to[b * s + j].emplace_back(a * s + (j | (1 << idx)), c);
            }
            else
            {
                to[a * s + j].emplace_back(b * s + j, c);
                to[b * s + j].emplace_back(a * s + j, c);
            }
        }
        if (must.at(i))
        {
            idx++;
        }
    }
    vector<int> dist(n * s, 2e9);
    priority_queue<edge, vector<edge>, greater<edge>> q;
    q.emplace(0, 0);
    while (not q.empty())
    {
        auto [d0, v] = q.top();
        q.pop();
        if (d0 >= dist.at(v))
        {
            continue;
        }
        dist.at(v) = d0;
        for (auto &&[c, d_edge] : to[v])
        {
            if (d0 + d_edge >= dist.at(c))
            {
                continue;
            }
            q.emplace(d0 + d_edge, c);
        }
    }
    cout << dist.back() << endl;
    return 0;
}
0