結果
| 問題 | No.1 道のショートカット |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-04 14:29:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,687 bytes |
| コンパイル時間 | 1,041 ms |
| コンパイル使用メモリ | 106,388 KB |
| 最終ジャッジ日時 | 2025-02-09 23:13:05 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:72:49: error: too many initializers for ‘P’ {aka ‘std::array<int, 3>’}
72 | G[s[i]-1].push_back(P{t[i]-1, y[i], m[i]});
| ^
main.cpp:81:19: error: no match for ‘operator[]’ (operand types are ‘std::array<int, 3>’ and ‘int’)
81 | if(j+e[1] > c) continue;
| ^
main.cpp:82:34: error: no match for ‘operator[]’ (operand types are ‘std::array<int, 3>’ and ‘int’)
82 | auto cost2 = cost + e[2];
| ^
main.cpp:83:20: error: no match for ‘operator[]’ (operand types are ‘std::array<int, 3>’ and ‘int’)
83 | if(dp[e[0]][j+e[1]] <= cost2) continue;
| ^
main.cpp:83:28: error: no match for ‘operator[]’ (operand types are ‘std::array<int, 3>’ and ‘int’)
83 | if(dp[e[0]][j+e[1]] <= cost2) continue;
| ^
main.cpp:84:17: error: no match for ‘operator[]’ (operand types are ‘std::array<int, 3>’ and ‘int’)
84 | dp[e[0]][j+e[1]] = cost2;
| ^
main.cpp:84:25: error: no match for ‘operator[]’ (operand types are ‘std::array<int, 3>’ and ‘int’)
84 | dp[e[0]][j+e[1]] = cost2;
| ^
main.cpp:85:24: error: no match for ‘operator[]’ (operand types are ‘std::array<int, 3>’ and ‘int’)
85 | Q.emplace(e[0], j+e[1], dp[e[0]][j+e[1]]);
| ^
main.cpp:85:32: error: no match for ‘operator[]’ (operand types are ‘std::array<int, 3>’ and ‘int’)
85 | Q.emplace(e[0], j+e[1], dp[e[0]][j+e[1]]);
| ^
main.cpp:85:41: error: no match for ‘operator[]’ (operand types are ‘std::array<int, 3>’ and ‘int’)
85 | Q.emplace(e[0], j+e[1], dp
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;
template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }
template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }
template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }
template <typename T>
struct edge {
int from, to; T cost;
edge(int to, T cost) : from(-1), to(to), cost(cost) {}
edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template <typename T>
vector<T> dijkstra(int s,vector<vector<edge<T>>> &G){
auto n = G.size();
vector<T> d(n, INF<T>);
priority_queue<pair<T, int>,vector<pair<T, int>>,greater<>> Q;
d[s] = 0;
Q.emplace(0, s);
while(!Q.empty()){
T cost; int i;
tie(cost, i) = Q.top(); Q.pop();
if(d[i] < cost) continue;
for (auto &&e : G[i]) {
auto cost2 = cost + e.cost;
if(d[e.to] <= cost2) continue;
d[e.to] = cost2;
Q.emplace(d[e.to], e.to);
}
}
return d;
}
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;
int main() {
int n, c, v;
cin >> n >> c >> v;
auto dp = make_v(n, c+1, INF<int>);
dp[0][0] = 0;
using P = array<int, 3>;
vector<vector<P>> G(n);
vector<int> s(v), t(v), y(v), m(v);
for (auto &&i : s) scanf("%d", &i);
for (auto &&i : t) scanf("%d", &i);
for (auto &&i : y) scanf("%d", &i);
for (auto &&i : m) scanf("%d", &i);
for (int i = 0; i < v; ++i) {
G[s[i]-1].push_back(P{t[i]-1, y[i], m[i]});
}
GPQ<tuple<int, int, int>> Q;
Q.emplace(0, 0, 0);
while(!Q.empty()){
int i, j, cost;
tie(i, j, cost) = Q.top(); Q.pop();
if(dp[i][j] < cost) continue;
for (auto &&e : G[i]) {
if(j+e[1] > c) continue;
auto cost2 = cost + e[2];
if(dp[e[0]][j+e[1]] <= cost2) continue;
dp[e[0]][j+e[1]] = cost2;
Q.emplace(e[0], j+e[1], dp[e[0]][j+e[1]]);
}
}
int ans = *min_element(dp.back().begin(),dp.back().end());
cout << (ans == INF<int> ? -1 : ans) << "\n";
return 0;
}