結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
illanasty
|
| 提出日時 | 2021-12-23 19:43:38 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,649 bytes |
| コンパイル時間 | 3,169 ms |
| コンパイル使用メモリ | 146,916 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-17 18:21:20 |
| 合計ジャッジ時間 | 4,605 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 WA * 24 RE * 6 |
ソースコード
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using LL = long long;
using LD = long double;
#define ALL(v) begin(v), end(v)
#define REP(i, n) for (LL i = 0; (i) < (LL)(n); ++(i))
#define REPR(i, n) for (LL i = (LL)(n)-1; (i) >= 0; --(i))
#define REP2(i, n, m) for (LL i = (LL)(n); (i) < (LL)(m); ++(i))
#define REP2R(i, n, m) for (LL i = (LL)(n)-1; (i) >= (LL)(m); --(i))
#define INF 1000000000
#define MAXV 55
#define MAXC 305
int V, C, E;
int S[MAXV], T[MAXV], Y[MAXV], M[MAXV];
int DP[MAXV][MAXC];
int main() {
cin >> V >> C >> E;
REP(i, E) {
cin >> S[i];
--S[i];
}
REP(i, E) {
cin >> T[i];
--T[i];
}
REP(i, E) cin >> Y[i];
REP(i, E) cin >> M[i];
REP(i, MAXV) REP(j, MAXC) DP[i][j] = INF;
using Data = tuple<int,int,int>;
priority_queue<Data,vector<Data>,greater<Data>> que;
que.push({0, 0, C});
DP[0][C] = 0;
while (!que.empty()) {
auto [dis, now, coin] = que.top();
que.pop();
if (DP[now][coin] < dis) continue;
REP(i, E) {
if (S[i] != now) continue;
if (Y[i] > coin) continue;
if (DP[T[i]][coin - Y[i]] > dis + M[i]) {
DP[T[i]][coin - Y[i]] = dis + M[i];
que.push({dis + M[i], T[i], coin - Y[i]});
}
}
}
int ans = INF;
REP(i, MAXC) ans = min(ans, DP[V-1][i]);
cout << (ans == INF ? -1 : ans) << endl;
return 0;
}
illanasty