Submission #1234782

#TimeUsernameProblemLanguageResultExecution timeMemory
1234782nasjesJourney (NOI18_journey)C++20
20 / 100
0 ms580 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*(1e3)+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}); } } 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=min(j+val, m+1); dp[i][cur]+=dp[x.fi][j]; } } for(int j=0; j<=m; j++){ dp[i][j]+=dp[i][j-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...