92602024-02-19 12:47:39AblablablaHálózati átvitelcpp17Wrong answer 1/5028ms7336 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[k] = 0;
    for(int x : megoldas){
        cout << x << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base1/50
1Accepted0/03ms1816 KiB
2Wrong answer0/03ms2068 KiB
3Accepted1/13ms2264 KiB
4Wrong answer0/13ms2516 KiB
5Wrong answer0/23ms2736 KiB
6Wrong answer0/23ms2880 KiB
7Wrong answer0/24ms2880 KiB
8Wrong answer0/24ms3196 KiB
9Wrong answer0/14ms3164 KiB
10Wrong answer0/14ms3456 KiB
11Wrong answer0/16ms3940 KiB
12Wrong answer0/18ms4020 KiB
13Wrong answer0/26ms3740 KiB
14Wrong answer0/28ms4056 KiB
15Wrong answer0/213ms4816 KiB
16Wrong answer0/213ms5072 KiB
17Wrong answer0/213ms5288 KiB
18Wrong answer0/213ms5176 KiB
19Wrong answer0/213ms5428 KiB
20Wrong answer0/213ms5644 KiB
21Wrong answer0/113ms5796 KiB
22Wrong answer0/117ms5876 KiB
23Wrong answer0/121ms6316 KiB
24Wrong answer0/125ms6664 KiB
25Wrong answer0/226ms7152 KiB
26Wrong answer0/225ms6892 KiB
27Wrong answer0/228ms7188 KiB
28Wrong answer0/225ms7132 KiB
29Wrong answer0/225ms7128 KiB
30Wrong answer0/224ms7212 KiB
31Wrong answer0/224ms7212 KiB
32Wrong answer0/225ms7336 KiB