44702023-03-28 12:34:51AGergoHálózati átvitelcpp11Time limit exceeded 0/50640ms63104 KiB
#include <bits/stdc++.h>

using namespace std;
vector<int> T;
vector<vector<int>> graf;
vector<vector<int>> speed;
int csomo,vonal,koz,H;

void bejar(int item,int szint,int t)
{
    if( szint <= H)
    {for(int y : graf[item])
        {
            if(y != koz)
            {
                if(t > speed[item][y])
                {
                    if(speed[item][y] > T[y]){T[y] = speed[item][y];}
                    bejar(y,szint+1,T[y]);
                }
                else
                {
                    if(t > T[y]){T[y] = t;}
                    bejar(y,szint+1,T[y]);
                }
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);

    cin >> csomo >> vonal >> koz >> H ;

    T.resize(csomo+1);
    graf.resize(csomo+1);
    speed.resize(csomo+1,vector<int>(csomo+1,-1));
    int a,b;
    for(int i = 0; i < vonal;i++)
    {
        cin >> a >> b;
        graf[a].push_back(b);
        graf[b].push_back(a);
        //cout << 1;
        cin >> speed[a][b];
        //cout << 2;
        speed[b][a] = speed[a][b];
        //cout << 3;
    }

    for(int x : graf[koz])
    {
        //cout << x;
        T[x] = speed[koz][x];
        bejar(x,1,speed[koz][x]);
    }

    for(int i = 1; i < csomo+1; i++)
    {
        cout << T[i] << "\n";
    }

}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms1696 KiB
2Time limit exceeded0/0563ms2116 KiB
3Wrong answer0/13ms2404 KiB
4Wrong answer0/13ms2308 KiB
5Time limit exceeded0/2558ms1608 KiB
6Time limit exceeded0/2564ms2412 KiB
7Time limit exceeded0/2555ms2676 KiB
8Time limit exceeded0/2640ms2628 KiB
9Time limit exceeded0/1560ms5804 KiB
10Time limit exceeded0/1573ms6064 KiB
11Time limit exceeded0/1556ms6368 KiB
12Time limit exceeded0/1573ms6328 KiB
13Time limit exceeded0/2579ms6624 KiB
14Time limit exceeded0/2577ms6852 KiB
15Time limit exceeded0/2640ms7116 KiB
16Time limit exceeded0/2552ms7064 KiB
17Time limit exceeded0/2560ms7300 KiB
18Time limit exceeded0/2564ms7348 KiB
19Time limit exceeded0/2568ms7292 KiB
20Time limit exceeded0/2572ms7284 KiB
21Runtime error0/132ms63104 KiB
22Runtime error0/132ms63068 KiB
23Runtime error0/127ms63040 KiB
24Runtime error0/132ms63016 KiB
25Runtime error0/227ms62988 KiB
26Runtime error0/226ms62752 KiB
27Runtime error0/226ms62516 KiB
28Runtime error0/226ms62504 KiB
29Runtime error0/230ms62484 KiB
30Runtime error0/227ms62280 KiB
31Runtime error0/227ms62264 KiB
32Runtime error0/226ms62272 KiB