結果
| 問題 |
No.3111 Toll Optimization
|
| コンテスト | |
| ユーザー |
mencotton
|
| 提出日時 | 2025-04-19 01:01:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,067 bytes |
| コンパイル時間 | 1,079 ms |
| コンパイル使用メモリ | 83,112 KB |
| 実行使用メモリ | 49,872 KB |
| 最終ジャッジ日時 | 2025-04-19 01:01:24 |
| 合計ジャッジ時間 | 16,621 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 66 WA * 4 |
ソースコード
#include <iostream>
#include <vector>
#include <cassert>
#include <queue>
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1 << 30) - 10;
const ll LINF = 1LL << 60;
inline void output_YesNo(bool x) { cout << (x ? "Yes" : "No") << endl; }
template<typename T>
inline void chmax(T &lhs, const T &rhs) { lhs = max(lhs, rhs); }
template<typename T>
inline void chmin(T &lhs, const T &rhs) { lhs = min(lhs, rhs); }
// #include <iomanip>
//
// void init_output() { cout << fixed << setprecision(15); }
struct edge {
int to;
ll cost;
};
struct status {
ll cost;
int v;
bool operator<(const status &rhs) const { return cost < rhs.cost; };
bool operator>(const status &rhs) const { return cost > rhs.cost; };
};
vector<ll> dijkstra(int s, vector<vector<edge>> &graph) {
priority_queue<status, vector<status>, greater<>> que;
vector<ll> dis(graph.size(), LINF);
dis[s] = 0;
que.push({0, s});
while (!que.empty()) {
status now = que.top();
que.pop();
if (dis[now.v] < now.cost)continue;
for (auto next: graph[now.v]) {
if (dis[next.to] > now.cost + next.cost) {
dis[next.to] = now.cost + next.cost;
que.push({dis[next.to], next.to});
}
}
}
return dis;
}
int main() {
int n, m, k;
cin >> n >> m >> k;
vector<ll> cost(m);
for (auto &x: cost)cin >> x;
vector<vector<edge>> graph(n * (k + 1));
for (int i = 0; i < m; i++) {
int from, to;
cin >> from >> to, from--, to--;
for (int j = 0; j <= k; j++) {
int u = from + n * j;
int v = to + n * j;
graph[u].push_back({v, cost[i]});
graph[v].push_back({u, cost[i]});
if (j >= 1) {
graph[u].push_back({v - n, 0});
graph[v].push_back({u - n, 0});
}
}
}
vector<ll> dis = dijkstra(n * k, graph);
cout << (dis[n - 1] >= LINF ? -1 : dis[n - 1]) << endl;
return 0;
}
mencotton