34042023-02-27 12:55:27kdbHálózati átvitelcpp11Wrong answer 42/5032ms6408 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;
    ki.erase(ki.begin());
    cout << ki;
    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/03ms1828 KiB
2Accepted0/03ms1972 KiB
3Wrong answer0/13ms2176 KiB
4Wrong answer0/13ms2384 KiB
5Accepted2/23ms2476 KiB
6Accepted2/23ms2744 KiB
7Accepted2/23ms2720 KiB
8Accepted2/23ms2720 KiB
9Wrong answer0/13ms3060 KiB
10Wrong answer0/14ms3292 KiB
11Accepted1/14ms3636 KiB
12Accepted1/14ms3920 KiB
13Accepted2/24ms4068 KiB
14Accepted2/24ms4080 KiB
15Accepted2/28ms4312 KiB
16Accepted2/27ms4348 KiB
17Accepted2/28ms4628 KiB
18Accepted2/28ms4860 KiB
19Accepted2/28ms4744 KiB
20Accepted2/28ms4736 KiB
21Wrong answer0/118ms5368 KiB
22Wrong answer0/121ms5496 KiB
23Wrong answer0/124ms5848 KiB
24Wrong answer0/127ms6156 KiB
25Accepted2/232ms6252 KiB
26Accepted2/232ms6100 KiB
27Accepted2/232ms6356 KiB
28Accepted2/217ms6384 KiB
29Accepted2/217ms6392 KiB
30Accepted2/217ms6408 KiB
31Accepted2/217ms6408 KiB
32Accepted2/218ms6384 KiB