252252026-02-18 16:10:37szabel26Hálózati átvitelcpp17Wrong answer 1/5056ms1820 KiB
#include <iostream>
#include <vector>
#include <deque>
#include <map>
#define ll long long
using namespace std;

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

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

void bejar(ll akt, ll 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 (ll i = 1; i <= m; ++i)
    {
        ll 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 (ll i = 1; i <= n; ++i)
        cout << x[i].koltseg << endl;
}
SubtaskSumTestVerdictTimeMemory
base1/50
1Accepted0/01ms316 KiB
2Wrong answer0/01ms508 KiB
3Accepted1/11ms316 KiB
4Wrong answer0/11ms324 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/22ms316 KiB
8Wrong answer0/22ms316 KiB
9Wrong answer0/13ms316 KiB
10Wrong answer0/14ms316 KiB
11Wrong answer0/17ms564 KiB
12Wrong answer0/18ms564 KiB
13Wrong answer0/26ms628 KiB
14Wrong answer0/27ms692 KiB
15Wrong answer0/213ms956 KiB
16Wrong answer0/212ms748 KiB
17Wrong answer0/212ms908 KiB
18Wrong answer0/214ms932 KiB
19Wrong answer0/213ms732 KiB
20Wrong answer0/213ms720 KiB
21Wrong answer0/126ms1208 KiB
22Wrong answer0/132ms1332 KiB
23Wrong answer0/145ms1584 KiB
24Wrong answer0/148ms1672 KiB
25Wrong answer0/252ms1592 KiB
26Wrong answer0/254ms1592 KiB
27Wrong answer0/256ms1820 KiB
28Wrong answer0/235ms1712 KiB
29Wrong answer0/234ms1712 KiB
30Wrong answer0/235ms1708 KiB
31Wrong answer0/234ms1712 KiB
32Wrong answer0/232ms1716 KiB