151492025-02-14 09:02:40csdavidHálózati átvitelcpp17Wrong answer 0/5025ms5072 KiB
#include <iostream>
#include <vector>
#include <queue>
/*#include <fstream>
#define cin fin
std::ifstream fin("be2.txt");*/
using namespace std;

struct csucs{
    vector<pair<int, int>> szomszed;
    int maxsebesseg=-1;
    bool q=0;
    int dp[101];
};

int x, y, z, n, m, k, h;
csucs a[10000];
queue<int> q;

int main()
{
    cin >> n >> m >> k >> h;
    k--;
    for(int i=0; i<m; i++){
        cin >> x >> y >> z;
        x--;
        y--;
        a[x].szomszed.push_back(make_pair(y, z));
        a[y].szomszed.push_back(make_pair(y, z));
        for(auto& it:a[i].dp){
            it=0;
        }
    }
    a[k].maxsebesseg=1000000;
    a[k].dp[0]=1000000;
    q.push(k);
    while(!q.empty()){
        x=q.front();
        a[x].q=0;
        //cout << x+1 << " -> ";
        q.pop();
        for(pair<int, int>& it:a[x].szomszed){
            int speed=it.second;
            bool push=0;
            y=it.first;
            for(int i=0; i<h; i++){
                if(min(a[x].dp[i], speed)>a[y].dp[i+1]){
                    a[y].dp[i+1]=min(a[x].dp[i], speed);
                    push=1;
                    a[y].maxsebesseg=max(a[y].maxsebesseg, a[y].dp[i+1]);
                }
            }
            if(push&&!a[y].q){
                q.push(y);
                a[y].q=1;
            }
            /*if(min(a[x].sebesseg, it.second)>a[it.first].sebesseg&&a[x].tav<h){
                a[it.first].sebesseg=min(a[x].sebesseg, it.second);
                a[it.first].tav=a[x].tav+1;
                q.push(it.first);
            }*/
        }
    }
    a[k].maxsebesseg=0;
    for(int i=0; i<n; i++){
        cout << a[i].maxsebesseg << '\n';
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/04ms4660 KiB
2Wrong answer0/04ms4660 KiB
3Wrong answer0/14ms4660 KiB
4Wrong answer0/14ms4660 KiB
5Wrong answer0/24ms4596 KiB
6Wrong answer0/24ms4852 KiB
7Wrong answer0/26ms4660 KiB
8Wrong answer0/24ms4668 KiB
9Wrong answer0/16ms4660 KiB
10Wrong answer0/17ms4660 KiB
11Wrong answer0/18ms4660 KiB
12Wrong answer0/19ms4852 KiB
13Wrong answer0/29ms4836 KiB
14Wrong answer0/210ms4876 KiB
15Wrong answer0/225ms4984 KiB
16Wrong answer0/218ms4892 KiB
17Wrong answer0/219ms4992 KiB
18Wrong answer0/225ms4988 KiB
19Wrong answer0/225ms5004 KiB
20Wrong answer0/220ms4776 KiB
21Wrong answer0/114ms5028 KiB
22Runtime error0/116ms4976 KiB
23Runtime error0/117ms4984 KiB
24Runtime error0/117ms4916 KiB
25Runtime error0/216ms5028 KiB
26Runtime error0/216ms4952 KiB
27Runtime error0/216ms5056 KiB
28Runtime error0/214ms5000 KiB
29Runtime error0/216ms5000 KiB
30Runtime error0/216ms4916 KiB
31Runtime error0/214ms4932 KiB
32Runtime error0/214ms5072 KiB