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 <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
#include <stack>
#include <iomanip>
#include <assert.h>
#include <bitset>
//#include "cycle.h"
using namespace std;
#define ll long long
//cin.tie(0);ios_base::sync_with_stdio(0);
const int MAXN = 1e4+5;
const int MAXM = 405;
const int MAXH = 105;
ll dp[MAXN][MAXM];
int main() {
int n, m, h;
cin >> n >> m >> h;
vector<pair<int, int>> adjList[MAXN];
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < h; j++) {
int a, b;
cin >> a >> b;
if (a <= i) {
continue;
}
adjList[i].push_back({ a, b });
}
}
dp[0][0] = 1;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if(i != 0)
dp[i][j + 1] += dp[i][j];
for (auto k : adjList[i]) {
if (j + k.second < m) {
dp[k.first][j + k.second] += dp[i][j];
}
}
}
}
for (int i = 0; i < m; i++) {
if (dp[n - 1][i] > 5 * 1e8) {
cout << 500000001 << endl;
}
else {
cout << dp[n - 1][i] << endl;
}
}
}
# | 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... |