93932024-02-21 12:09:52csaron71Hálózati átvitelcpp17Wrong answer 0/5037ms18616 KiB
#include <bits/stdc++.h>
#include <queue>
using namespace std;

int main() {
	int n, m, k, h;
	cin >> n >> m >> k >> h;
	vector<vector<pair<int, int> > > elek(n+1, vector<pair<int, int> >());
	for (int i=0; i<m; i++)  {
		int x, y, z;
		cin >> x >> y >> z;
		elek[x].push_back({y, z});
		elek[y].push_back({x, z});
	}

	vector<vector<int> > tav(n+1, vector<int>(h+1, -10e5-1));
	tav[k][0]=10e5+1;
	priority_queue<pair<int, pair<int, int> > > sor; //hany, honnan, hova
	vector<bool> volt(n+1, false);
	volt[k]=true;
	sor.push({0, {k, k}});
	while (sor.size()>0) {
		int messze=sor.top().first;
		int honnan=sor.top().second.first;
		int hova=sor.top().second.second;
		sor.pop();
		volt[hova]=true;
		//cout << hova << ": ";
		for (int i=1; i<h+1; i++) {
			tav[hova][i]=max(tav[hova][i], min(messze, tav[honnan][i-1]));
			//cout << tav[hova][i] << " ";
		}
		//cout << "\n";
		for (pair<int, int> sz : elek[hova]) {
			if (volt[sz.first]==false) {
				sor.push({sz.second, {hova, sz.first}});
			}

		}
	}

	for (int i=1; i<n+1; i++) {
		int epp=-10e5+1;
		for (int j=0; j<h+1; j++) {
			//cout << tav[i][j]<< " ";
			epp=max(epp, tav[i][j]);
		}
		//cout << epp << "\n";
		if (epp==10e5+1) {
			cout << "0\n";
		}
		else {
			cout << epp << "\n";
		}
	}
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms1808 KiB
2Wrong answer0/03ms2096 KiB
3Wrong answer0/13ms2292 KiB
4Wrong answer0/13ms2460 KiB
5Wrong answer0/23ms2692 KiB
6Wrong answer0/23ms2780 KiB
7Wrong answer0/24ms2896 KiB
8Wrong answer0/24ms3232 KiB
9Wrong answer0/14ms3412 KiB
10Wrong answer0/14ms3704 KiB
11Wrong answer0/17ms4112 KiB
12Wrong answer0/18ms4488 KiB
13Wrong answer0/27ms4464 KiB
14Wrong answer0/28ms4632 KiB
15Wrong answer0/214ms5440 KiB
16Wrong answer0/214ms5352 KiB
17Wrong answer0/214ms5576 KiB
18Wrong answer0/216ms6120 KiB
19Wrong answer0/214ms6020 KiB
20Wrong answer0/214ms6184 KiB
21Wrong answer0/119ms13312 KiB
22Wrong answer0/125ms13764 KiB
23Wrong answer0/129ms13896 KiB
24Wrong answer0/134ms15024 KiB
25Wrong answer0/235ms16836 KiB
26Wrong answer0/235ms16716 KiB
27Wrong answer0/237ms17424 KiB
28Wrong answer0/229ms16200 KiB
29Wrong answer0/232ms17800 KiB
30Wrong answer0/230ms18016 KiB
31Wrong answer0/230ms18352 KiB
32Wrong answer0/232ms18616 KiB