44642023-03-28 11:49:31UnluckYHálózati átvitelcpp11Wrong answer 40/50560ms38944 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

ll INF = 100001;

int main(){

    int n, m, k, h; cin >> n >> m >> k >> h;
    vector<vector<pair<int, int>>> v(n+1);

    for (int i = 0; i < m; i++){
        int a, b, c; cin >> a >> b >> c;
        v[a].push_back({b, c});
        v[b].push_back({a, c});
    } 

    vector<vector<int>> d(n+1, vector<int>(h+1, 0));
    priority_queue<pair<int, pair<int, int>>> q;
    q.push({INF, {k, 0}});
    d[k][0] = INF;

    while(!q.empty()){
        int dis = q.top().first;
        int x = q.top().second.first;
        int y = q.top().second.second;
        q.pop();
        if (dis < d[x][y] || y >= h) continue;

        for (pair<int, int> i : v[x]){
            if (min(dis, i.second) > d[i.first][y+1]){
                d[i.first][y+1] = min(dis, i.second);
                q.push({d[i.first][y+1], {i.first, y+1}});
            }
        }
    }

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

    //cout << d[3][2] << endl;

    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= h; j++){
            dd[i] = max(dd[i], d[i][j]);
        }
    }

    dd[k] = 0;



    for (int i = 1; i <= n; i++){cout << dd[i] << endl;}

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/50
1Accepted0/03ms1812 KiB
2Accepted0/03ms2032 KiB
3Wrong answer0/13ms2228 KiB
4Wrong answer0/13ms2444 KiB
5Accepted2/23ms2656 KiB
6Accepted2/24ms3072 KiB
7Accepted2/24ms3260 KiB
8Accepted2/24ms3588 KiB
9Wrong answer0/16ms4032 KiB
10Wrong answer0/113ms4492 KiB
11Accepted1/123ms4952 KiB
12Accepted1/118ms5084 KiB
13Accepted2/221ms5056 KiB
14Accepted2/223ms5332 KiB
15Accepted2/254ms8032 KiB
16Accepted2/232ms6576 KiB
17Accepted2/243ms6588 KiB
18Accepted2/270ms8360 KiB
19Accepted2/254ms8248 KiB
20Accepted2/243ms6624 KiB
21Wrong answer0/1167ms14236 KiB
22Wrong answer0/1248ms18748 KiB
23Wrong answer0/1307ms24736 KiB
24Wrong answer0/1402ms25104 KiB
25Accepted2/2524ms26756 KiB
26Accepted2/2517ms26740 KiB
27Time limit exceeded0/2560ms21160 KiB
28Accepted2/2384ms37656 KiB
29Accepted2/2470ms38852 KiB
30Accepted2/2451ms38844 KiB
31Accepted2/2421ms38840 KiB
32Accepted2/2453ms38944 KiB