34052023-02-27 13:00:33kdbHálózati átvitelcpp11Wrong answer 42/5032ms6560 KiB
#include <iostream>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;

std::ostream& operator<<(std::ostream& os, const std::vector<int>& input)
{
    for (auto const& i : input) {
        os << i << "\n";
    }
    return os;
}

int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n, m, k, h;
    cin >> n >> m >> k >> h;
    vector<int>ki(n + 1);
    vector<int>ki2(n + 1);
    vector<vector<pair<int, int>>>vec(n + 1);

    for (size_t i = 0; i < m; i++)
    {
        int u, v, w;
        cin >> u >> v >> w;
        vec[u].push_back({ v,w });
        vec[v].push_back({ u,w });
    }

    ki[k] = INT_MAX;
    ki2[k] = INT_MAX;

    for (size_t i = 0; i < h; i++)
    {
        for (size_t j = 1; j < n + 1; j++)
        {
            for (auto q : vec[j])
            {
                if (ki[q.first] < min(q.second, ki2[j]))
                {
                    ki[q.first] = min(q.second, ki2[j]);
                }
            }
        }
        ki2 = ki;
    }
    ki[k] = 0;
    for (size_t i = 1; i < n + 1; i++)
    {
        cout << ki[i] << "\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
*/
SubtaskSumTestVerdictTimeMemory
base42/50
1Accepted0/03ms1704 KiB
2Accepted0/03ms2072 KiB
3Wrong answer0/13ms2144 KiB
4Wrong answer0/13ms2352 KiB
5Accepted2/23ms2516 KiB
6Accepted2/23ms2864 KiB
7Accepted2/23ms3220 KiB
8Accepted2/23ms3172 KiB
9Wrong answer0/13ms3140 KiB
10Wrong answer0/14ms3100 KiB
11Accepted1/14ms3540 KiB
12Accepted1/16ms3976 KiB
13Accepted2/24ms3800 KiB
14Accepted2/24ms3932 KiB
15Accepted2/28ms4048 KiB
16Accepted2/27ms4056 KiB
17Accepted2/28ms4020 KiB
18Accepted2/28ms4148 KiB
19Accepted2/28ms4420 KiB
20Accepted2/28ms4372 KiB
21Wrong answer0/119ms4996 KiB
22Wrong answer0/123ms5368 KiB
23Wrong answer0/124ms5504 KiB
24Wrong answer0/127ms5728 KiB
25Accepted2/232ms5984 KiB
26Accepted2/232ms5940 KiB
27Accepted2/232ms6196 KiB
28Accepted2/217ms6256 KiB
29Accepted2/218ms6320 KiB
30Accepted2/217ms6484 KiB
31Accepted2/217ms6560 KiB
32Accepted2/218ms6536 KiB