250512026-02-17 15:40:22szabel26Hálózati átvitelcpp17Wrong answer 1/5076ms2848 KiB
#include <iostream>
#include <vector>
#include <deque>
#include <map>
using namespace std;

struct adat
{
    int csp, koltseg = -1;
    map<int, int> sz; // map vagy matrix szukseges
};

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;

        if (x[a].sz[b] > c || x[a].sz[b] == 0)
        {
            x[a].sz[b] = c;
            x[b].sz[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/01ms316 KiB
2Wrong answer0/02ms316 KiB
3Accepted1/11ms316 KiB
4Wrong answer0/11ms316 KiB
5Wrong answer0/22ms316 KiB
6Wrong answer0/22ms404 KiB
7Wrong answer0/22ms452 KiB
8Wrong answer0/22ms420 KiB
9Wrong answer0/13ms316 KiB
10Wrong answer0/14ms564 KiB
11Wrong answer0/18ms564 KiB
12Wrong answer0/19ms836 KiB
13Wrong answer0/28ms564 KiB
14Wrong answer0/29ms828 KiB
15Wrong answer0/225ms1396 KiB
16Wrong answer0/219ms1400 KiB
17Wrong answer0/223ms1332 KiB
18Wrong answer0/229ms1336 KiB
19Wrong answer0/225ms1212 KiB
20Wrong answer0/220ms1392 KiB
21Wrong answer0/128ms1588 KiB
22Wrong answer0/141ms2092 KiB
23Wrong answer0/157ms2364 KiB
24Wrong answer0/176ms2576 KiB
25Wrong answer0/268ms2696 KiB
26Wrong answer0/265ms2612 KiB
27Wrong answer0/275ms2752 KiB
28Wrong answer0/241ms2612 KiB
29Wrong answer0/241ms2604 KiB
30Wrong answer0/239ms2644 KiB
31Wrong answer0/241ms2740 KiB
32Wrong answer0/241ms2848 KiB