This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define bb back
#define ff first
#define ss second
#define int long long
using namespace std;
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, m, h;
cin >> n >> m >> h;
vector<vector<pair<int, int> > > path(n, vector<pair<int, int> >(h));
for (int i = 0; i < n-1; i++)
for (int j = 0; j < h; j++)
cin >> path[i][j].ff >> path[i][j].ss;
vector<int> ans(m+5, 0);
vector<vector<int> > reach(n, vector<int>(m, 0));
reach[0][0] = 1;
for (int i = 0; i < n-1; i++) {
for (int k = 0; k < m; k++) {
for (int p = 0; p < h; p++) {
if (path[i][p].ff <= i)
continue;
for (int j = path[i][p].ss+k; j < m; j++)
reach[path[i][p].ff][j] += reach[i][k];
}
}
}
for (int i = 0; i < m; i++)
cout << reach[n-1][i] << ' ';
cout << '\n';
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... |