210902026-01-12 11:27:29csdavidHálózati átvitelcpp17Time limit exceeded 35/50600ms5496 KiB
#include <iostream>
#include <vector>
using namespace std;

struct node{
    int maxi=-1;
    int speed[101] = {-1};
    vector<pair<int, int>> szomszed;
};

node a[10000];
int n, k, h;
void bejar(int x, int tav){
    a[x].maxi=max(a[x].maxi, a[x].speed[tav]);
    if(tav==h){
        return;
    }
    //cout << "\n\nx: " << x << "\ntav: " << tav;
    for(pair<int, int> i: a[x].szomszed){
        if(x==3&&i.first==2){
            //cout << "\n\na[x].speed[tav]: " << a[x].speed[tav];
            //cout << "a[i.first].speed[tav+1]): " << a[i.first].speed[tav+1];
        }
        if(min(a[x].speed[tav], i.second)>a[i.first].speed[tav+1]){
            a[i.first].speed[tav+1]=min(a[x].speed[tav], i.second);
            bejar(i.first, tav+1);
        }
    }
}

int main()
{
    pair<int, int> x;
    int k, b, c, y, m;
    cin >> n >> m >> k >> h;
    k--;
    while(m--){
        cin >> b >> c >> y;
        b--;
        c--;
        a[c].szomszed.push_back(make_pair(b, y));
        a[b].szomszed.push_back(make_pair(c, y));
    }
    a[k].speed[0]=9999999;
    bejar(k, 0);
    a[k].maxi=0;
    for(int i=0; i<n; i++){
        cout << a[i].maxi << '\n';
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base35/50
1Accepted0/04ms4524 KiB
2Accepted0/04ms4404 KiB
3Accepted1/14ms4404 KiB
4Accepted1/14ms4404 KiB
5Accepted2/24ms4404 KiB
6Accepted2/26ms4404 KiB
7Accepted2/24ms4660 KiB
8Accepted2/26ms4676 KiB
9Accepted1/16ms4640 KiB
10Accepted1/110ms4708 KiB
11Accepted1/123ms4672 KiB
12Accepted1/117ms4880 KiB
13Accepted2/221ms4660 KiB
14Accepted2/225ms4868 KiB
15Accepted2/268ms4836 KiB
16Accepted2/235ms5048 KiB
17Accepted2/248ms4912 KiB
18Accepted2/285ms5000 KiB
19Accepted2/271ms4828 KiB
20Accepted2/250ms5148 KiB
21Accepted1/1162ms4916 KiB
22Accepted1/1377ms5136 KiB
23Accepted1/1389ms5432 KiB
24Time limit exceeded0/1556ms5496 KiB
25Time limit exceeded0/2575ms5496 KiB
26Time limit exceeded0/2587ms5428 KiB
27Time limit exceeded0/2586ms5428 KiB
28Accepted2/2451ms5432 KiB
29Time limit exceeded0/2584ms5428 KiB
30Time limit exceeded0/2583ms5428 KiB
31Time limit exceeded0/2575ms5428 KiB
32Time limit exceeded0/2600ms5368 KiB