43232023-03-24 13:24:46horvathabelHálózati átvitelcpp17Time limit exceeded 0/50648ms4872 KiB
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int>> g[10001];
vector<int> mego;

void dfs(int x, int level, int cel){
	if (level>cel) return;
	if (level==0){
		for (auto edge:g[x]){
			mego[edge.first]=edge.second; 
			dfs(edge.first, level+1, cel);
		}
	}
	for (auto edge:g[x]){
		mego[edge.first]=max(mego[edge.first],min(edge.second, mego[x]));
		dfs(edge.first, level+1, cel);
	}
}
int main() {
	int n,m,c,k;
	cin>>n>>m>>c>>k;
	for (int i=0; i<m;i++){
		int x,y,v;
		cin>>x>>y>>v;
		g[x].push_back({y,v});
		g[y].push_back({x,v});
	}
	mego.assign(n+1,0);
	dfs(c,0,k);
	for (int i=1; i<=n;i++){
		if (i==c) cout<<0<<endl;
		else cout<<mego[i]<<endl; 
	}
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms2520 KiB
2Time limit exceeded0/0600ms1680 KiB
3Wrong answer0/13ms2992 KiB
4Wrong answer0/14ms3280 KiB
5Time limit exceeded0/2564ms2252 KiB
6Time limit exceeded0/2574ms3504 KiB
7Time limit exceeded0/2555ms2504 KiB
8Time limit exceeded0/2572ms3936 KiB
9Time limit exceeded0/1572ms2800 KiB
10Time limit exceeded0/1568ms2876 KiB
11Time limit exceeded0/1564ms3288 KiB
12Time limit exceeded0/1572ms3284 KiB
13Time limit exceeded0/2579ms3216 KiB
14Time limit exceeded0/2572ms3412 KiB
15Time limit exceeded0/2551ms3596 KiB
16Time limit exceeded0/2560ms3640 KiB
17Time limit exceeded0/2564ms3700 KiB
18Time limit exceeded0/2552ms3724 KiB
19Time limit exceeded0/2577ms3828 KiB
20Time limit exceeded0/2569ms4024 KiB
21Time limit exceeded0/1564ms4260 KiB
22Time limit exceeded0/1552ms4580 KiB
23Time limit exceeded0/1560ms4656 KiB
24Time limit exceeded0/1564ms4700 KiB
25Time limit exceeded0/2569ms4720 KiB
26Time limit exceeded0/2568ms4776 KiB
27Time limit exceeded0/2579ms4780 KiB
28Time limit exceeded0/2560ms4784 KiB
29Time limit exceeded0/2569ms4868 KiB
30Time limit exceeded0/2640ms4856 KiB
31Time limit exceeded0/2612ms4772 KiB
32Time limit exceeded0/2648ms4872 KiB