Submission #1234830

#TimeUsernameProblemLanguageResultExecution timeMemory
1234830nasjesJourney (NOI18_journey)C++20
20 / 100
1 ms1604 KiB
#include <iostream> #include <iomanip> #include <vector> #include <cmath> #include <algorithm> #include <set> #include <queue> #include <map> #include <stack> #include <bitset> #include <string> #include <cstring> #include <iterator> #include <random> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef long double ld; const ll dim = 5*1e4+7; //const ll mod = 1e9 + 7; const ll inf = 1e18 + 77; #define endl "\n" #define fi first #define pb push_back #define se second #define vll vector<ll> ll n, m; ll t=0; vector<pll> a[dim]; ll dp[dim][500]; int main() { ll d, k; cin>>n>>m>>k; for(int i=1; i<=n-1; i++) { for (int j = 1; j <= k; j++) { ll u, w; cin >> u >> w; u++; a[u].pb({i, w}); } } for(int i=0; i<=m; i++){ dp[1][i]=1;} dp[1][0]=1; for(int i=2; i<=n; i++) { for (auto x: a[i]) { ll val = x.se; for (int j = 0; j <= m; j++) { ll cur = j + val; if (j + val > m)continue; dp[i][cur] += dp[x.fi][j]; dp[i][cur] = min<ll>(dp[i][cur], 5e8 + 1); } } if (i != n) { for (int j = 1; j <= m; j++) { dp[i][j] += dp[i][j - 1]; dp[i][j] = min<ll>(dp[i][j], 5e8 + 1); } } } ll sum=0; for(int i=0; i<=m-1; i++ ){ cout<<dp[n][i]<<" "; } cout<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...