92612024-02-19 13:53:49AblablablaHálózati átvitelcpp17Accepted 50/5045ms13300 KiB
#include <bits/stdc++.h>

using namespace std;

const int INF = 2e9 + 7;

struct el{
    int a;
    int b;
    int c;
};

int main(){
    int n, m, k, h;
    cin >> n >> m >> k >> h;
    k--;

    vector<el> elek(m);
    for(int i = 0; i < m; i++){
        cin >> elek[i].a >> elek[i].b >> elek[i].c;
        elek[i].a--; elek[i].b--;
    }

    vector<vector<int>> dp(n, vector<int>(h + 1, 0));

    for(int i = 0; i < n; i++){
        dp[i][0] = -1;
    }

    dp[k][0] = INF;

    for(int j = 1; j <= h; j++){
        for(int i = 0; i < n; i++){
            dp[i][j] = dp[i][j - 1];
        }

        for(int i = 0; i < m; i++){
            int a = elek[i].a;
            int b = elek[i].b;
            int c = elek[i].c;

            dp[a][j] = max(dp[a][j], min(dp[b][j - 1], c));
            dp[b][j] = max(dp[b][j], min(dp[a][j - 1], c));
        }
    }

    for(int i = 0; i < n; i++){
        cout << (dp[i][h] == INF ? 0 : dp[i][h]) << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1944 KiB
2Accepted0/03ms2148 KiB
3Accepted1/13ms2372 KiB
4Accepted1/13ms2492 KiB
5Accepted2/23ms2640 KiB
6Accepted2/23ms2788 KiB
7Accepted2/23ms2856 KiB
8Accepted2/23ms2964 KiB
9Accepted1/14ms2952 KiB
10Accepted1/14ms3120 KiB
11Accepted1/16ms3176 KiB
12Accepted1/17ms3148 KiB
13Accepted2/26ms3496 KiB
14Accepted2/27ms3460 KiB
15Accepted2/213ms3636 KiB
16Accepted2/212ms3724 KiB
17Accepted2/213ms4004 KiB
18Accepted2/214ms4108 KiB
19Accepted2/213ms4304 KiB
20Accepted2/212ms4124 KiB
21Accepted1/123ms10820 KiB
22Accepted1/127ms10644 KiB
23Accepted1/130ms10588 KiB
24Accepted1/135ms10780 KiB
25Accepted2/243ms12420 KiB
26Accepted2/241ms12744 KiB
27Accepted2/245ms12992 KiB
28Accepted2/241ms12048 KiB
29Accepted2/245ms12940 KiB
30Accepted2/243ms13192 KiB
31Accepted2/241ms13300 KiB
32Accepted2/243ms13152 KiB