結果
| 問題 | No.3616 WK vs AT vs MT vs SP |
| コンテスト | |
| ユーザー |
kwm_t
|
| 提出日時 | 2026-08-10 01:45:23 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 188 ms / 2,000 ms |
| + 896µs | |
| コード長 | 2,777 bytes |
| 記録 | |
| コンパイル時間 | 2,895 ms |
| コンパイル使用メモリ | 357,748 KB |
| 実行使用メモリ | 25,648 KB |
| 最終ジャッジ日時 | 2026-08-10 01:45:33 |
| 合計ジャッジ時間 | 7,860 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| サンプル | 0 % | AC * 1 |
| 小課題1 | 8 % | AC * 9 |
| 小課題2 | 16 % | AC * 5 |
| 小課題3 | 20 % | AC * 10 |
| 小課題4 | 20 % | AC * 15 |
| 小課題5 | 20 % | AC * 15 |
| 小課題6 | 16 % | AC * 36 |
| 合計 | 2.5 * 100% = 250 点 |
ソースコード
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
// using namespace atcoder;
// using mint = modint1000000007;
// const int mod = 1000000007;
// using mint = modint998244353;
// const int mod = 998244353;
// const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, l, r) for (int i = (l); i < (r); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, l, r) for (int i = (r)-1; i >= (l); --i)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
#define P pair<int, int>
template<typename A, typename B> inline bool chmax(A& a, const B& b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A& a, const B& b) { if (a > b) { a = b; return true; } return false; }
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, r;
long long c; cin >> n >> r >> c;
vector<long long>x(n), y(n), z(n), s(n);
rep(i, n)cin >> x[i];//o-toma
rep(i, n)cin >> y[i];//manyuaru
rep(i, n)cin >> z[i];//hune
rep(i, n)cin >> s[i];//ふねじかん
vector e(n, vector<array<int, 4>>());
rep(i, r) {
int u, v, w, a, m; cin >> u >> v >> w >> a >> m;
u--, v--;
// toho o-toma manyuaru
e[u].push_back({ v,w,a,m });
e[v].push_back({ u,w,a,m });
}
vector dp(n + 1, vector(3, vector<long long>(2, LINF)));
dp[0][0][0] = 0;
using S = std::pair<long long, array<int, 3>>;
std::priority_queue<S, std::vector<S>, std::greater<S>> pq;
pq.push({ dp[0][0][0], { 0,0,0 } });
while (!pq.empty()) {
auto [cost, state] = pq.top();
pq.pop();
auto [v, s0, s1] = state;
if (cost != dp[v][s0][s1])continue;
// 空港は特別
if (v == n) {
rep(nv, n) {
if (chmin(dp[nv][s0][s1], cost + c + s[nv])) {
pq.push({ dp[nv][s0][s1], { nv,s0,s1 } });
}
}
continue;
}
rep(i, 3)rep(j, 2) {
auto ncost = cost;
if (i == 1)ncost += x[v];
if (i == 2)ncost += y[v];
if (j == 1)ncost += z[v];
int ns0 = max(i, s0);
int ns1 = max(j, s1);
for (auto tmp : e[v]) {
auto [nv, w, a, m] = tmp;
{// toho
if (chmin(dp[nv][ns0][ns1], ncost + w)) {
pq.push({ dp[nv][ns0][ns1], { nv,ns0,ns1 } });
}
}
if (1 <= ns0) {// o-toma
if (chmin(dp[nv][ns0][ns1], ncost + a)) {
pq.push({ dp[nv][ns0][ns1], { nv,ns0,ns1 } });
}
}
if (2 <= ns0) {// manyuaru
if (chmin(dp[nv][ns0][ns1], ncost + m)) {
pq.push({ dp[nv][ns0][ns1], { nv,ns0,ns1 } });
}
}
}
if (1 <= ns1) {
if (chmin(dp[n][ns0][ns1], ncost + s[v])) {
pq.push({ dp[n][ns0][ns1], { n,ns0,ns1 } });
}
}
}
}
long long ans = LINF;
rep(i, 3)rep(j, 2)chmin(ans, dp[n - 1][i][j]);
cout << ans << endl;
return 0;
}
kwm_t