40082023-03-08 11:42:09tamasmarkHálózati átvitelcpp17Wrong answer 0/5028ms8004 KiB
// halozati atvitel.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <queue>
#include <climits>
#include <algorithm>

using namespace std;

struct ut
{
    long long hova, hossz;
};

struct adat
{
    bool lat;
    long long tav=LLONG_MIN,lep;
    vector<ut>sz;
};
priority_queue<ut>que;
ut akt;
bool operator<(const ut a, const ut b)
{
    return a.hossz < b.hossz;
}
int n, m, i, a, b, c, h, k;
vector<adat>x;
int main()
{
    cin >> n >> m >> k >> h;
    x.resize(n + 1);
    for (i = 1; i <= m; ++i)
    {
        cin >> a >> b >> c;
        x[a].sz.push_back({ b,c });
        x[b].sz.push_back({ a,c });
    }
    que.push({ k,LLONG_MAX });
    //x[k].lat = true;
    while (!que.empty())
    {
        akt = que.top();
        while (!que.empty() && x[akt.hova].lat)
        {
            que.pop();
            if (!que.empty()) akt = que.top();
        }
        if (que.empty()) break;
        x[akt.hova].lat = true;
        x[akt.hova].tav = akt.hossz;
        for (auto& e : x[akt.hova].sz)
        {
            if (!x[e.hova].lat && x[e.hova].tav < min(akt.hossz , e.hossz)&&x[akt.hova].lep<=h)
            {
                x[e.hova].tav = min(akt.hossz , e.hossz);
                x[e.hova].lep = x[akt.hova].lep + 1;
                que.push({ e.hova, min(e.hossz , akt.hossz) });
            }
        }
    }
    x[k].tav = 0;
    for (i = 1; i <= n; ++i)
    {
        cout << x[i].tav << "\n";
    }
    return 0;
}
/*
5 6 1 2
1 2 2
1 5 4
1 3 2
1 4 3
5 4 1
5 3 4
*/
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms1880 KiB
2Wrong answer0/03ms2148 KiB
3Wrong answer0/13ms2340 KiB
4Wrong answer0/13ms2552 KiB
5Wrong answer0/23ms2648 KiB
6Wrong answer0/23ms2668 KiB
7Wrong answer0/23ms2700 KiB
8Wrong answer0/23ms2960 KiB
9Wrong answer0/14ms2936 KiB
10Wrong answer0/14ms3384 KiB
11Wrong answer0/16ms3596 KiB
12Wrong answer0/18ms3940 KiB
13Wrong answer0/26ms4092 KiB
14Wrong answer0/27ms4128 KiB
15Wrong answer0/212ms4720 KiB
16Wrong answer0/212ms4676 KiB
17Wrong answer0/212ms4672 KiB
18Wrong answer0/212ms4928 KiB
19Wrong answer0/212ms5008 KiB
20Wrong answer0/212ms5000 KiB
21Wrong answer0/114ms5572 KiB
22Wrong answer0/118ms6224 KiB
23Wrong answer0/121ms6912 KiB
24Wrong answer0/125ms6804 KiB
25Wrong answer0/226ms7076 KiB
26Wrong answer0/226ms7128 KiB
27Wrong answer0/228ms7620 KiB
28Wrong answer0/225ms7336 KiB
29Wrong answer0/226ms7336 KiB
30Wrong answer0/224ms7248 KiB
31Wrong answer0/224ms7484 KiB
32Wrong answer0/225ms8004 KiB