95712024-02-23 10:42:56hackemonHálózati átvitelcpp17Runtime error 1/50115ms64716 KiB
#include <bits/stdc++.h>
#define pii pair<int, int>
using namespace std;

int n, m, k, h;
vector<vector<pii>> adj;
vector<int> mindist;
int main() {    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> k >> h; 
    adj.resize(n + 1); 
    mindist.resize(n + 1, -1); 
    for(int i = 0;i < m;i++ ) { 
        int a, b, c;
        cin >> a >> b >> c; 
        adj[a].push_back({b, c});
        adj[b].push_back({a, c});
    }
    queue<pii> pontok; 
    pontok.push({k, 0});
    

    for(int i = 0;i < h;i++ ) { 
        int meret = pontok.size();
        for(int j = 0;j < meret;j++ ) { 
            pii f = pontok.front(); 
            pontok.pop(); 
            for(int z = 0;z < adj[f.first].size();z++ ) {
                int cel = adj[f.first][z].first; 
                int ertek = adj[f.first][z].second;

                if(f.first == k) { 
                    mindist[cel] = max(mindist[cel], ertek);
                } else { 
                    mindist[cel] = max(mindist[cel], min(ertek, mindist[f.first]));
                }
                pontok.push({cel, mindist[cel]});
            }
        }
    }
    mindist[k] = 0; 
    for(int i = 1;i <= n;i++ ) { 
        cout << mindist[i] << endl;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base1/50
1Accepted0/03ms1832 KiB
2Runtime error0/093ms64716 KiB
3Accepted1/13ms2400 KiB
4Wrong answer0/13ms2836 KiB
5Runtime error0/296ms64168 KiB
6Runtime error0/287ms63936 KiB
7Runtime error0/283ms63700 KiB
8Runtime error0/283ms63672 KiB
9Runtime error0/1108ms63600 KiB
10Runtime error0/1101ms63580 KiB
11Runtime error0/192ms63580 KiB
12Runtime error0/189ms63340 KiB
13Runtime error0/292ms63188 KiB
14Runtime error0/287ms63176 KiB
15Runtime error0/286ms63172 KiB
16Runtime error0/286ms63168 KiB
17Runtime error0/286ms63164 KiB
18Runtime error0/286ms63172 KiB
19Runtime error0/286ms63172 KiB
20Runtime error0/286ms63172 KiB
21Runtime error0/1114ms63160 KiB
22Runtime error0/1115ms63168 KiB
23Runtime error0/1112ms63172 KiB
24Runtime error0/1111ms63180 KiB
25Runtime error0/2112ms63164 KiB
26Runtime error0/2112ms63168 KiB
27Runtime error0/2112ms63172 KiB
28Runtime error0/281ms63176 KiB
29Runtime error0/279ms63172 KiB
30Runtime error0/279ms63172 KiB
31Runtime error0/279ms63144 KiB
32Runtime error0/281ms63156 KiB