66272023-12-13 21:42:04mmatedHálózati átvitelcpp17Wrong answer 0/5035ms9896 KiB
#include <bits/stdc++.h>
using namespace std;
#define f(i,k,n) for(int i=k; i<n; i++)
#define ll long long
const int inf = INT_MAX;

void solve()
{
    int n,m,k,h;
    cin>>n>>m>>k>>h;
    vector<vector<pair<int,int>>> g(n+1);
    vector<int> d(n);
    int a,b,w;
    f(i,0,m)
    {
        cin>>a>>b>>w;
        g[a].push_back({b,w});
        g[b].push_back({a,w});
    }  
    f(i,0,n)    d[i]=0;
    d[k-1]=0;
    f(i,1,h+1)
    {
        f(j,1,n+1)
        {
            int maxi=d[j];
            for(auto e : g[j])
            {
                int a=j;
                int b=e.first;
                int w=e.second;
                if(d[a]>0)  maxi=max(maxi, min(d[a],w));
                else    maxi=max(maxi,w);
            }
            d[j]=maxi;
        }
    }
    f(i,1,n+1)
    {
        if(i==k)    cout<<0<<"\n";
        else    cout<<d[i]<<"\n";
    }

}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--)  solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms1972 KiB
2Wrong answer0/03ms2164 KiB
3Wrong answer0/13ms2228 KiB
4Wrong answer0/13ms2360 KiB
5Wrong answer0/23ms2584 KiB
6Wrong answer0/23ms2860 KiB
7Wrong answer0/23ms2968 KiB
8Wrong answer0/23ms2944 KiB
9Wrong answer0/13ms3112 KiB
10Wrong answer0/14ms3316 KiB
11Wrong answer0/14ms3384 KiB
12Wrong answer0/14ms3768 KiB
13Wrong answer0/24ms3588 KiB
14Wrong answer0/26ms4088 KiB
15Wrong answer0/28ms4364 KiB
16Wrong answer0/28ms4500 KiB
17Wrong answer0/28ms4644 KiB
18Wrong answer0/29ms4776 KiB
19Wrong answer0/28ms4912 KiB
20Wrong answer0/28ms5068 KiB
21Wrong answer0/121ms5764 KiB
22Wrong answer0/124ms6328 KiB
23Wrong answer0/126ms6616 KiB
24Wrong answer0/128ms7268 KiB
25Wrong answer0/234ms7724 KiB
26Wrong answer0/232ms7808 KiB
27Wrong answer0/235ms8216 KiB
28Wrong answer0/219ms8644 KiB
29Wrong answer0/221ms9100 KiB
30Wrong answer0/221ms9448 KiB
31Wrong answer0/220ms9780 KiB
32Wrong answer0/221ms9896 KiB