44042023-03-27 17:16:46horvathabelHálózati átvitelcpp17Wrong answer 6/5046ms4740 KiB
#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>,int>> g;
bool seen[100001];

int main() {
	int n,m,k,h;
	cin>>n>>m>>k>>h;
	for (int i=0; i<m;i++){
		int x,y,c;
		cin>>x>>y>>c; 
		g.push_back({{x,y},c});
	}
	vector<int> dp;
	dp.resize(n+1,0);
	dp[k]=1e9;
	for (int j=1; j<=h;j++){
			for (pair<pair<int,int>, int> edge:g){
				if (dp[edge.first.first]!=1e9) dp[edge.first.first]=max(dp[edge.first.first],min(dp[edge.first.second],edge.second));
				if (dp[edge.first.second]!=1e9) dp[edge.first.second]=max(dp[edge.first.second],min(dp[edge.first.first],edge.second));
		}
	}
	for (int i=1; i<=n;i++){
		if (i==k) cout<<0<<endl; 
		else{
		 if (dp[i]==0) cout<<-1<<endl;
		 else cout<<dp[i]<<endl;
		}
	} 
}
SubtaskSumTestVerdictTimeMemory
base6/50
1Accepted0/03ms1820 KiB
2Wrong answer0/03ms2056 KiB
3Wrong answer0/13ms2288 KiB
4Wrong answer0/13ms2456 KiB
5Wrong answer0/23ms2672 KiB
6Wrong answer0/23ms2884 KiB
7Wrong answer0/23ms3112 KiB
8Wrong answer0/23ms3180 KiB
9Wrong answer0/14ms3172 KiB
10Wrong answer0/14ms3544 KiB
11Accepted1/17ms3564 KiB
12Wrong answer0/18ms3624 KiB
13Wrong answer0/27ms3696 KiB
14Wrong answer0/28ms3864 KiB
15Wrong answer0/214ms4036 KiB
16Wrong answer0/213ms4028 KiB
17Wrong answer0/214ms4076 KiB
18Wrong answer0/214ms4080 KiB
19Wrong answer0/214ms4076 KiB
20Wrong answer0/213ms4180 KiB
21Accepted1/126ms4028 KiB
22Wrong answer0/132ms4100 KiB
23Accepted1/134ms4248 KiB
24Accepted1/139ms4484 KiB
25Wrong answer0/239ms4480 KiB
26Wrong answer0/246ms4480 KiB
27Accepted2/241ms4484 KiB
28Wrong answer0/239ms4484 KiB
29Wrong answer0/241ms4740 KiB
30Wrong answer0/239ms4696 KiB
31Wrong answer0/239ms4696 KiB
32Wrong answer0/241ms4700 KiB