80712024-01-12 11:59:22Huni136Hálózati átvitelcpp17Wrong answer 10/5057ms10440 KiB
#include <iostream>
#include <vector>
using namespace std;
int n,h,kezd;
vector<vector<pair<int,int>>> vc(10001);
//vector<int> tav(10001,1e9);

void bellmanford()
{
    vector<int> tav1(n+1,-1);
    vector<int> tav2(n+1,-1);
    tav1[kezd]=1e9;
    tav2[kezd]=1e9;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(auto it: vc[j])
            {
                // tav[it.first]=min(tav[it.first],it.second);
                if(tav1[it.first]<min(it.second,tav2[j]))
                {
                    tav1[it.first]=min(it.second,tav2[j]);
                }
            }
        }
        tav2=tav1;
    }
    tav1[kezd]=0;
    for(int i=1;i<=n;i++)
    {
        cout<<(tav1[i]!=-1?tav1[i]:-1)<<endl;
    }
}

int main()
{
    int m, k;
    cin>>n>>m>>kezd>>h;
    int x,y,z;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y>>z;
        vc[x].emplace_back(y,z);
    }

    bellmanford();

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base10/50
1Accepted0/03ms2068 KiB
2Wrong answer0/03ms2272 KiB
3Wrong answer0/13ms2508 KiB
4Wrong answer0/13ms2728 KiB
5Wrong answer0/23ms2916 KiB
6Wrong answer0/23ms3164 KiB
7Wrong answer0/24ms3368 KiB
8Wrong answer0/24ms3720 KiB
9Wrong answer0/14ms3712 KiB
10Wrong answer0/16ms4008 KiB
11Wrong answer0/18ms4312 KiB
12Wrong answer0/18ms4328 KiB
13Wrong answer0/28ms4252 KiB
14Wrong answer0/28ms4728 KiB
15Wrong answer0/214ms5120 KiB
16Wrong answer0/214ms5248 KiB
17Wrong answer0/214ms5372 KiB
18Wrong answer0/214ms5552 KiB
19Wrong answer0/214ms5840 KiB
20Wrong answer0/214ms6220 KiB
21Wrong answer0/130ms6456 KiB
22Wrong answer0/139ms7128 KiB
23Wrong answer0/143ms7236 KiB
24Wrong answer0/152ms7984 KiB
25Wrong answer0/250ms8472 KiB
26Wrong answer0/254ms8632 KiB
27Wrong answer0/257ms8884 KiB
28Accepted2/237ms9304 KiB
29Accepted2/243ms9704 KiB
30Accepted2/246ms9720 KiB
31Accepted2/241ms9992 KiB
32Accepted2/241ms10440 KiB