11312022-03-12 15:50:45nmarciHálózati átvitelcpp11Accepted 50/5068ms16360 KiB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <list>

using namespace std;
using ll = long long int;

int maxa[10010][110];
struct Edge
{
    int a, b, w;
};

int main()
{
    int n, m, k, h;
    cin >> n >> m >> k >> h;
    for(int i = 1; i <= n; ++i){
        maxa[i][0] = -1;
    }
    maxa[k][0] = numeric_limits<int>::max();
    vector<Edge> v;
    for(int a = 0; a < m; ++a){
        Edge i;
        cin >> i.a >> i.b >> i.w;
        v.push_back(i);
        swap(i.a, i.b);
        v.push_back(i);
    }
    for(int i = 1; i <= h; ++i){
        for(int j = 1;  j <= n; ++j)
            maxa[j][i] = maxa[j][i - 1];
        for(auto e : v){
            maxa[e.a][i] = max(maxa[e.a][i], min(maxa[e.b][i - 1], e.w));
            //maxa[e.b] = max(maxa[e.b], min(maxa[e.a], e.w));
        }
    }
    for(int i = 1; i <= n; ++i){
        if(i == k) cout << 0 << endl;
        else cout << maxa[i][h] << endl;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1744 KiB
2Accepted0/02ms1976 KiB
3Accepted1/11ms1896 KiB
4Accepted1/12ms1904 KiB
5Accepted2/21ms1908 KiB
6Accepted2/22ms1924 KiB
7Accepted2/22ms1952 KiB
8Accepted2/22ms1976 KiB
9Accepted1/13ms2752 KiB
10Accepted1/14ms2940 KiB
11Accepted1/17ms3132 KiB
12Accepted1/18ms3392 KiB
13Accepted2/26ms3256 KiB
14Accepted2/28ms3516 KiB
15Accepted2/214ms4156 KiB
16Accepted2/219ms4292 KiB
17Accepted2/213ms4368 KiB
18Accepted2/216ms4560 KiB
19Accepted2/214ms4684 KiB
20Accepted2/214ms4820 KiB
21Accepted1/137ms12640 KiB
22Accepted1/143ms12800 KiB
23Accepted1/146ms13108 KiB
24Accepted1/157ms14044 KiB
25Accepted2/264ms14400 KiB
26Accepted2/261ms14688 KiB
27Accepted2/268ms14964 KiB
28Accepted2/257ms15176 KiB
29Accepted2/261ms15552 KiB
30Accepted2/257ms15700 KiB
31Accepted2/261ms15968 KiB
32Accepted2/264ms16360 KiB