Submission #586397

# Submission time Handle Problem Language Result Execution time Memory
586397 2022-06-30T08:24:42 Z Jomnoi Journey (NOI18_journey) C++17
20 / 100
1 ms 568 KB
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 10005;
const int MAX_M = 405;
const int MOD = 500000001;

int dp[MAX_N][MAX_M];
vector <pair <int, int>> graph[MAX_N];

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int N, M, H;
    cin >> N >> M >> H;

    for(int i = 0; i < N - 1; i++) {
        for(int h = 0; h < H; h++) {
            int j, k;
            cin >> j >> k;

            graph[i].emplace_back(j, k);
        }
    }

    dp[0][0] = 1;
    for(int i = 0; i < N - 1; i++) {
        for(int m = 1; m < M; m++) {
            dp[i][m] += dp[i][m - 1];
            dp[i][m] = min(dp[i][m], MOD);
        }

        for(auto [j, k] : graph[i]) {
            for(int m = 0; m + k < M; m++) {
                dp[j][m + k] += dp[i][m];
                dp[j][m + k] = min(dp[j][m + k], MOD);
            }
        }
    }

    for(int m = 0; m < M; m++) {
        cout << dp[N - 1][m] << ' ';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 568 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Incorrect 1 ms 568 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Incorrect 1 ms 568 KB Output isn't correct
4 Halted 0 ms 0 KB -