This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 1e4+100;
const int MAXM = 4e2+100;
const ll MAX = 5e8+1;
int N, M, H;
vector<pii> g[MAXN];
ll dp[MAXM][MAXN];
void solve(){
cin >> N >> M >> H;
rep(i, 0, N - 1){
rep(h, 0, H){
int j, w;
cin >> j >> w;
if(j > i)
g[i].pb({j, w});
}
}
dp[0][0] = 1;
rep(v, 0, N - 1){
rep(m, 0, M){
dp[m + 1][v] += dp[m][v];
}
for(auto [u, w] : g[v]){
per(m, M, w){
dp[m][u] = min(MAX, dp[m][u] + dp[m - w][v]);
}
}
}
rep(m, 0, M){
cout << dp[m][N - 1] << " ";
}
}
int main(){
ios_base::sync_with_stdio(false), cin.tie(nullptr);
solve();
return 0;
}
Compilation message (stderr)
journey.cpp: In function 'void solve()':
journey.cpp:42:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
42 | for(auto [u, w] : g[v]){
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |