13212022-05-13 18:56:10nkdorka1212Hálózati átvitelcpp11Wrong answer 3/5054ms7572 KiB
#include <bits/stdc++.h>

using namespace std;

int n,m,k,h;
vector<vector<pair<int,int>>>g;
vector<int>velocity;
vector<bool>pos;

void bellmann_ford()
{
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(auto x:g[j])
            {
                if(velocity[x.first]<min(velocity[j],x.second))
                {
                    velocity[x.first]=min(velocity[j],x.second);
                }
            }
        }
    }
}

int main()
{
    cin>>n>>m>>k>>h;
    velocity.resize(n+1,0);
    g.resize(n+1);
    pos.resize(n+1);
    for(int i=1;i<=m;i++)
    {
        int u,v,w;
        cin>>u>>v>>w;
        g[u].push_back({v,w});
        g[v].push_back({u,w});
    }
    velocity[k]=INT_MAX;
    bellmann_ford();
    for(int i=1;i<=n;i++)
    {
        if(i==k)
        {
            cout<<0<<'\n';
        }else
        {
            cout<<velocity[i]<<'\n';
        }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base3/50
1Accepted0/02ms1832 KiB
2Wrong answer0/01ms1860 KiB
3Wrong answer0/12ms1912 KiB
4Wrong answer0/12ms1920 KiB
5Wrong answer0/21ms1936 KiB
6Wrong answer0/21ms1944 KiB
7Wrong answer0/22ms1964 KiB
8Wrong answer0/22ms1984 KiB
9Wrong answer0/12ms2020 KiB
10Wrong answer0/14ms2060 KiB
11Accepted1/14ms2280 KiB
12Wrong answer0/17ms2496 KiB
13Wrong answer0/28ms2396 KiB
14Wrong answer0/27ms2612 KiB
15Wrong answer0/210ms2940 KiB
16Wrong answer0/29ms3068 KiB
17Wrong answer0/29ms3196 KiB
18Wrong answer0/213ms3104 KiB
19Wrong answer0/213ms3228 KiB
20Wrong answer0/210ms3360 KiB
21Wrong answer0/120ms3812 KiB
22Wrong answer0/128ms4384 KiB
23Wrong answer0/130ms4704 KiB
24Wrong answer0/137ms4992 KiB
25Wrong answer0/243ms5612 KiB
26Wrong answer0/241ms5868 KiB
27Accepted2/254ms6244 KiB
28Wrong answer0/225ms6484 KiB
29Wrong answer0/226ms6768 KiB
30Wrong answer0/237ms7024 KiB
31Wrong answer0/225ms7292 KiB
32Wrong answer0/227ms7572 KiB