239862026-02-03 08:29:39szabelrHálózati átvitelcpp17Wrong answer 6/5037ms1800 KiB
// Hálózati átvitel.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <queue>
#include <climits>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, k, h;
    cin >> n >> m >> k >> h;
    vector<vector<pair<int,int>>> adj(n + 1);
    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        adj[a].push_back({ b,c });
        adj[b].push_back({ a,c });
    }
    vector<int> mini(n + 1, -1);
    mini[k] = 0;
    queue<pair<int, pair<int, int>>> q;
    q.push({ 0,{k,INT_MAX} });
    while (!q.empty())
    {
        auto it = q.front();
        q.pop();
        int stops = it.first;
        int node = it.second.first;
        int speed = it.second.second;
        if (stops > h) continue;
        for (auto iterator : adj[node])
        {
            int adjNode = iterator.first;
            int curSpeed = iterator.second;
            if (min(speed, curSpeed) > mini[adjNode])
            {
                mini[adjNode] = min(speed, curSpeed);
                q.push({ stops + 1,{adjNode,mini[adjNode]} });
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if (i != k)
            cout << mini[i] << endl;
        else
            cout << 0 << endl;
    }
       

}
SubtaskSumTestVerdictTimeMemory
base6/50
1Accepted0/01ms492 KiB
2Wrong answer0/01ms508 KiB
3Wrong answer0/11ms316 KiB
4Wrong answer0/11ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms356 KiB
7Wrong answer0/22ms564 KiB
8Wrong answer0/22ms560 KiB
9Wrong answer0/13ms508 KiB
10Wrong answer0/13ms316 KiB
11Accepted1/14ms564 KiB
12Wrong answer0/14ms580 KiB
13Wrong answer0/24ms624 KiB
14Wrong answer0/24ms564 KiB
15Wrong answer0/27ms708 KiB
16Wrong answer0/28ms652 KiB
17Wrong answer0/27ms820 KiB
18Wrong answer0/27ms892 KiB
19Wrong answer0/27ms880 KiB
20Wrong answer0/27ms824 KiB
21Accepted1/119ms1188 KiB
22Wrong answer0/126ms1412 KiB
23Accepted1/127ms1364 KiB
24Accepted1/128ms1208 KiB
25Wrong answer0/232ms1280 KiB
26Wrong answer0/234ms1556 KiB
27Accepted2/232ms1800 KiB
28Wrong answer0/234ms1688 KiB
29Wrong answer0/235ms1388 KiB
30Wrong answer0/237ms1644 KiB
31Wrong answer0/237ms1628 KiB
32Wrong answer0/237ms1388 KiB