結果
| 問題 | No.3616 WK vs AT vs MT vs SP |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2026-08-09 21:47:42 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 96 ms / 2,000 ms |
| + 693µs | |
| コード長 | 2,261 bytes |
| 記録 | |
| コンパイル時間 | 406 ms |
| コンパイル使用メモリ | 80,148 KB |
| 実行使用メモリ | 38,860 KB |
| 最終ジャッジ日時 | 2026-08-09 21:47:52 |
| 合計ジャッジ時間 | 4,124 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_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 点 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 3616.cc: No.3616 WK vs AT vs MT vs SP - yukicoder
*/
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<utility>
using namespace std;
/* constant */
const int MAX_N = 30000;
const int L = 8;
const int MAX_GN = (MAX_N + 1) * L;
const long long LINF = 1LL << 60;
/* typedef */
using ll = long long;
using pil = pair<int,ll>;
using vpil = vector<pil>;
using pli = pair<ll,int>;
/* global variables */
int xs[MAX_N], ys[MAX_N], zs[MAX_N];
ll ss[MAX_N];
vpil nbrs[MAX_GN];
ll ds[MAX_GN];
/* subroutines */
/* main */
int main() {
int n, r;
ll c;
scanf("%d%d%lld", &n, &r, &c);
for (int i = 0; i < n; i++) scanf("%d", xs + i);
for (int i = 0; i < n; i++) scanf("%d", ys + i);
for (int i = 0; i < n; i++) scanf("%d", zs + i);
for (int i = 0; i < n; i++) scanf("%lld", ss + i);
for (int i = 0; i < r; i++) {
int up, vp, w, a, m;
scanf("%d%d%d%d%d", &up, &vp, &w, &a, &m);
up--, vp--;
a = min(w, a);
m = min(a, m);
ll lws[] = {w, a, m, m, w, a, m, m};
for (int l = 0; l < L; l++) {
int u = up * L + l, v = vp * L + l;
nbrs[u].push_back({v, lws[l]});
nbrs[v].push_back({u, lws[l]});
}
}
for (int l = 4; l < L; l++)
for (int up = 0; up < n; up++) {
int u = up * L + l, v = n * L + l;
nbrs[u].push_back({v, ss[up]});
nbrs[v].push_back({u, ss[up] + c});
}
int gn = (n + 1) * L;
fill(ds, ds + gn, LINF);
ds[0] = 0;
priority_queue<pli> q;
q.push({0, 0});
ll gd = -1;
while (! q.empty()) {
auto [ud, u] = q.top(); q.pop();
ud = -ud;
if (ds[u] != ud) continue;
int up = u / L, ul = u % L;
if (up == n - 1) { gd = ud; break; }
if (up < n) {
if (! (u & 1)) {
int v = (u | 1);
ll vd = ud + xs[up];
if (ds[v] > vd) ds[v] = vd, q.push({-vd, v});
}
if (! (u & 2)) {
int v = (u | 2);
ll vd = ud + ys[up];
if (ds[v] > vd) ds[v] = vd, q.push({-vd, v});
}
if (! (u & 4)) {
int v = (u | 4);
ll vd = ud + zs[up];
if (ds[v] > vd) ds[v] = vd, q.push({-vd, v});
}
}
for (auto [v, w]: nbrs[u]) {
ll vd = ud + w;
if (ds[v] > vd) ds[v] = vd, q.push({-vd, v});
}
}
printf("%lld\n", gd);
return 0;
}
tnakao0123