結果
| 問題 |
No.1812 Uribo Road
|
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2022-01-14 22:34:02 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,509 bytes |
| コンパイル時間 | 3,815 ms |
| コンパイル使用メモリ | 258,224 KB |
| 実行使用メモリ | 1,506,472 KB |
| 最終ジャッジ日時 | 2024-11-20 12:22:27 |
| 合計ジャッジ時間 | 35,394 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 TLE * 1 MLE * 12 |
ソースコード
#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;
}
trineutron