Submission #372027

# Submission time Handle Problem Language Result Execution time Memory
372027 2021-02-27T07:53:55 Z shrek12357 Journey (NOI18_journey) C++14
43 / 100
3 ms 876 KB
#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
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
5 Incorrect 3 ms 876 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
5 Incorrect 3 ms 876 KB Output isn't correct
6 Halted 0 ms 0 KB -