250002026-02-17 11:46:46szabel26Hálózati átvitelcpp17Wrong answer 1/5057ms1472 KiB
#include <iostream>
#include <vector>
#include <deque>
using namespace std;

struct adat
{
    int csp, koltseg = -1;
    vector<pair<int, int>> sz;
};

int n, m, kezd, max_hossz;
vector<adat> x;

void bejar(int akt, int lep)
{
    if (lep < max_hossz)
    {
        for (auto &e : x[akt].sz)
        {
            if (akt == kezd)
            {
                if (x[e.first].koltseg == -1 || x[e.first].koltseg < e.second)
                {
                    x[e.first].koltseg = e.second;
                    bejar(e.first, lep + 1);
                }
            }
            else
            {
                if ((x[e.first].koltseg == -1 || x[e.first].koltseg < min(e.second, x[akt].koltseg)) && e.first != kezd)
                {
                    x[e.first].koltseg = min(e.second, x[akt].koltseg);
                    bejar(e.first, lep + 1);
                }
            }
        }
    }
    else
        return;
}

int main()
{
    cin >> n >> m >> kezd >> max_hossz;
    x.resize(n + 1);

    for (int i = 1; i <= m; ++i)
    {
        int a, b, c;
        cin >> a >> b >> c;

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

    x[kezd].koltseg = 0;
    bejar(kezd, 0);

    for (int i = 1; i <= n; ++i)
        cout << x[i].koltseg << endl;
}
SubtaskSumTestVerdictTimeMemory
base1/50
1Accepted0/01ms500 KiB
2Wrong answer0/01ms316 KiB
3Accepted1/11ms316 KiB
4Wrong answer0/11ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/22ms316 KiB
8Wrong answer0/22ms316 KiB
9Wrong answer0/13ms316 KiB
10Wrong answer0/14ms472 KiB
11Wrong answer0/17ms456 KiB
12Wrong answer0/17ms564 KiB
13Wrong answer0/26ms564 KiB
14Wrong answer0/28ms564 KiB
15Wrong answer0/214ms716 KiB
16Wrong answer0/212ms712 KiB
17Wrong answer0/213ms720 KiB
18Wrong answer0/214ms564 KiB
19Wrong answer0/213ms564 KiB
20Wrong answer0/213ms688 KiB
21Wrong answer0/126ms1076 KiB
22Wrong answer0/134ms1132 KiB
23Wrong answer0/143ms1084 KiB
24Wrong answer0/146ms1112 KiB
25Wrong answer0/252ms1304 KiB
26Wrong answer0/257ms1360 KiB
27Wrong answer0/256ms1332 KiB
28Wrong answer0/237ms1332 KiB
29Wrong answer0/235ms1472 KiB
30Wrong answer0/237ms1248 KiB
31Wrong answer0/235ms1332 KiB
32Wrong answer0/235ms1332 KiB