Submission #515965

# Submission time Handle Problem Language Result Execution time Memory
515965 2022-01-20T08:17:40 Z Joo Journey (NOI18_journey) C++17
20 / 100
1 ms 972 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e4+10;

int n, M, H, dp[N][410];
vector<pair<int, int>> G[N];

inline void add(int &a, int b){
    if(a + b >= 500'000'001) a = 500000001;
    else a += b;
}

int main(void){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> M >> H;
    for(int i = 0; i < n-1; i++){
        for(int j = 0; j < H; j++){
            int v, mn; cin >> v >> mn;
            assert(v > i);
            G[i].emplace_back(v, mn);
        }
    }

    dp[0][0] = 1;
    for(int u = 0; u < n-1; u++){
        for(int m = 1; m < M; m++){
            add(dp[u][m], dp[u][m-1]);
        }

        for(auto [v, mn] : G[u]){
            for(int m = 0; m+mn < M; m++){
                add(dp[v][m+mn], dp[u][m]);
            }
        }
    }

    for(int m = 0; m < M; m++) cout << dp[n-1][m] << " ";
    cout << "\n";


    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 972 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Runtime error 1 ms 972 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Runtime error 1 ms 972 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -