답안 #1031184

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1031184 2024-07-22T15:54:41 Z vjudge1 Journey (NOI18_journey) C++17
20 / 100
1 ms 600 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define f first
#define s second

mt19937 gnd(time(NULL));

void solve(){
    int n, m, k;
    cin >> n >> m >> k;
    
    int dp[n+7][m+4];
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            dp[i][j]=0;
        }
    }
    // cout << "st" << endl;

    vector<vector<pair<int, int>>> v(n+4, vector<pair<int,int>> (k+3));
    
    for(int i = 0; i < n-1; i++){
        for(int j = 0; j < k; j++){
            cin >> v[i][j].f >> v[i][j].s;
        }
    }

    dp[0][0]=1;
    // cout << "med" << endl;
    for(int i = 0; i < n-1; i++){
        for(int j = 0; j <= m; j++){
            if(j > 0) dp[i][j]=min((int) 5e8+1, dp[i][j]+dp[i][j-1]);
            for(int kk = 0; kk < k; kk++){
                if(j+v[i][kk].second <= m){
                    // cout << i << " " << j << " " << kk << endl;
                    dp[v[i][kk].first][j+v[i][kk].second] = min((int) 5e8+1, dp[v[i][kk].first][j+v[i][kk].second]+dp[i][j]);
                }
            }
        }
    }

    for(int j = 0; j < m; j++){
        cout << min(dp[n-1][j], (int) 5e8+1) << " ";
    }
    cout << endl;


}


signed main(){
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) solve();

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -