92592024-02-19 12:45:58AblablablaHálózati átvitelcpp17Wrong answer 0/5028ms7372 KiB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

const int INF = 2e9 + 7;

struct pont{
    int a; // akt
    int t; // tav
    int h; // hasznalt
};

struct comp{
    bool operator()(pont a, pont b){
        return a.t < b.t;
    }
};

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

    vector<vector<pii>> csucsok(n, vector<pii>());
    for(int i = 0; i < m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;

        csucsok[a].push_back({b, c});
        csucsok[b].push_back({a, c});
    }

    priority_queue<pont, vector<pont>, comp> bejar;
    bejar.push({k, INF, 0});
    vector<bool> bejart(n, 0);
    vector<int> megoldas(n, -1);

    while(!bejar.empty()){
        int akt = bejar.top().a;
        int tav = bejar.top().t;
        int hasznalt = bejar.top().h;
        bejar.pop();

        if(hasznalt > h || bejart[akt]) continue;

        bejart[akt] = 1;
        megoldas[akt] = tav;

        for(pii x : csucsok[akt]){
            if(bejart[x.first]) continue;

            bejar.push({x.first, min(tav, x.second), hasznalt + 1});
        }
    }

    megoldas[0] = 0;
    for(int x : megoldas){
        cout << x << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms1816 KiB
2Wrong answer0/03ms2080 KiB
3Wrong answer0/13ms2120 KiB
4Wrong answer0/13ms2332 KiB
5Wrong answer0/23ms2552 KiB
6Wrong answer0/23ms2640 KiB
7Wrong answer0/23ms2680 KiB
8Wrong answer0/23ms2924 KiB
9Wrong answer0/14ms2888 KiB
10Wrong answer0/14ms3188 KiB
11Wrong answer0/16ms3688 KiB
12Wrong answer0/18ms3912 KiB
13Wrong answer0/26ms4080 KiB
14Wrong answer0/28ms4204 KiB
15Wrong answer0/213ms5232 KiB
16Wrong answer0/213ms5016 KiB
17Wrong answer0/213ms5284 KiB
18Wrong answer0/213ms5464 KiB
19Wrong answer0/213ms5508 KiB
20Wrong answer0/213ms5480 KiB
21Wrong answer0/114ms5616 KiB
22Wrong answer0/117ms5740 KiB
23Wrong answer0/121ms6308 KiB
24Wrong answer0/124ms6620 KiB
25Wrong answer0/226ms6992 KiB
26Wrong answer0/226ms6728 KiB
27Wrong answer0/228ms7364 KiB
28Wrong answer0/225ms7276 KiB
29Wrong answer0/226ms7276 KiB
30Wrong answer0/226ms7280 KiB
31Wrong answer0/224ms7372 KiB
32Wrong answer0/225ms7320 KiB