Untitled
unknown
plain_text
25 days ago
552 B
1
Indexable
Never
typedef unsigned long long ll; void solve() { int n,k; cin>>n>>k; vector<int>dp(n); vector<int>freq(n); vector<int>p(n); for (int i=0;i<n;i++) { cin>>p[i]; p[i]--; freq[p[i]]=i; } for (int l=1;l<=k;l++) { for (int i=0;i<n;++i) { dp[p[i]]++; // p[j]<p[i] & j<i dp[j]-> dp[i] for (int j=0;j<p[i];j++) { dp[p[i]]+=dp[j]; } } } for (int i=0;i<n;++i)cout<<dp[i]<<' '; cout<<endl; }
Leave a Comment