Submission #865420

#TimeUsernameProblemLanguageResultExecution timeMemory
865420Trisanu_DasJourney (NOI18_journey)C++17
69 / 100
81 ms39048 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define ff first #define ss second int n, m, h, vis[10005], dp[10005][405]; vector<pair<int, int> > adj[10005]; void dfs(int u){ if(u == n - 1) return; vis[u] = true; for(auto e : adj[u]){ int v = e.ff, w = e.ss; if(v < u) continue; if(!vis[v]) dfs(v); for(int i = w; i < m; i++){ dp[u][i] += dp[v][i - w]; dp[u][i] = min(dp[u][i], 500000001LL); } } for(int i = 1; i < m; i++) { dp[u][i] += dp[u][i - 1]; dp[u][i] = min(dp[u][i], 500000001LL); } } signed main(){ cin >> n >> m >> h; for(int u = 0; u < n - 1; u++){ for(int i = 0; i < h; i++){ int v, w; cin >> v >> w; adj[u].pb({v, w}); } } dp[n - 1][0] = 1; dfs(0); for(int i = 0; i < m; i++) cout << dp[0][i] << ' '; cout << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...