제출 #1133419

#제출 시각아이디문제언어결과실행 시간메모리
1133419AvianshJourney (NOI18_journey)C++20
100 / 100
39 ms7240 KiB
#include <bits/stdc++.h>

using namespace std;

int mxval = 5e8+1;

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m,h;
    cin >> n >> m >> h;
    long long ans[n][m];
    for(int i = 0;i<n;i++){
        fill(ans[i],ans[i]+m,0);
    }
    ans[0][0]=1;
    for(int i = 0;i<n-1;i++){
        for(int l = 0;l<h;l++){
            int j,k;
            cin >> j >> k;
            if(j<=i){
                continue;
            }
            int temp = 0;
            for(int d = 0;d<m-k;d++){
                temp+=ans[i][d];
                if(temp>=mxval){
                    temp=mxval;
                }
                ans[j][d+k]+=temp;
                if(ans[j][d+k]>=mxval){
                    ans[j][d+k]=mxval;
                }
            }
        }
    }
    int temp = 0;
    for(int d = 0;d<m;d++){
        temp=ans[n-1][d];
        assert(temp<=mxval);
        cout << temp << " ";
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...