#include <bits/stdc++.h>
using namespace std;
int mxval = 5e8+1;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,m,h;
cin >> n >> m >> h;
int ans[n][m];
for(int i = 0;i<n;i++){
fill(ans[i],ans[i]+m,0);
}
ans[0][0]=1;
for(int i = 0;i<n-1;i++){
for(int l = 0;l<h;l++){
int j,k;
cin >> j >> k;
int temp = 0;
for(int d = 0;d<m-k;d++){
temp+=ans[i][d];
if(temp>=5e8+1){
temp=5e8+1;
}
ans[j][d+k]+=temp;
if(ans[j][d+k]>=5e8+1){
ans[j][d+k]=5e8+1;
}
}
}
}
int temp = 0;
for(int d = 0;d<m;d++){
temp=ans[n-1][d];
cout << temp << " ";
}
return 0;
}
# | 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... |