43362023-03-25 15:36:38szilHálózati átvitelcpp14Wrong answer 6/5018ms6252 KiB
#include <bits/stdc++.h>
 
using ll = long long;
using namespace std;

const int MAXN = 100001;

struct Edge {
	int a, b, w;
};

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m, k, h;
	cin >> n >> m >> k >> h;

	vector<Edge> edges;
	for (int i = 0; i < m; i++) {
		Edge e;
		cin >> e.a >> e.b >> e.w;
		edges.push_back(e);
	}

	vector<int> d(MAXN, INT_MIN);
	d[k] = INT_MAX;
	for (int i = 0; i < h; i++) {
		for (Edge e : edges) {
			if (d[e.a] != INT_MIN)
				d[e.b] = max(d[e.b], min(d[e.a],e.w));
			if (d[e.b] != INT_MIN)
				d[e.a] = max(d[e.a], min(d[e.b],e.w));
		}
	}

	for (int i = 1; i <= n; i++) {
		if (d[i] < -1000000) {
			cout << "-1 ";
		} else {
			cout << (i==k?0:d[i]) << " ";
		}
	}
	cout << "\n";
}
SubtaskSumTestVerdictTimeMemory
base6/50
1Accepted0/03ms2796 KiB
2Wrong answer0/03ms3072 KiB
3Wrong answer0/13ms3024 KiB
4Wrong answer0/13ms3152 KiB
5Wrong answer0/23ms3356 KiB
6Wrong answer0/23ms3600 KiB
7Wrong answer0/23ms4072 KiB
8Wrong answer0/23ms3932 KiB
9Wrong answer0/13ms4236 KiB
10Wrong answer0/14ms4280 KiB
11Accepted1/14ms4412 KiB
12Wrong answer0/14ms4288 KiB
13Wrong answer0/24ms4452 KiB
14Wrong answer0/24ms4540 KiB
15Wrong answer0/27ms4768 KiB
16Wrong answer0/27ms5020 KiB
17Wrong answer0/27ms4964 KiB
18Wrong answer0/28ms5384 KiB
19Wrong answer0/27ms5060 KiB
20Wrong answer0/27ms5056 KiB
21Accepted1/18ms5048 KiB
22Wrong answer0/110ms5180 KiB
23Accepted1/113ms5424 KiB
24Accepted1/114ms5724 KiB
25Wrong answer0/217ms5832 KiB
26Wrong answer0/216ms5928 KiB
27Accepted2/217ms5920 KiB
28Wrong answer0/217ms5920 KiB
29Wrong answer0/218ms6164 KiB
30Wrong answer0/217ms6132 KiB
31Wrong answer0/217ms6196 KiB
32Wrong answer0/218ms6252 KiB