43372023-03-25 15:45:12szilHálózati átvitelcpp14Wrong answer 0/5035ms62556 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<vector<int>> d(h+1, vector<int>(MAXN, INT_MIN));
	for (int i = 0; i <= h; i++) d[i][k] = INT_MAX;
	for (int i = 1; i <= h; i++) {
		for (Edge e : edges) {
			if (d[i][e.a] != INT_MIN)
				d[i][e.b] = max(d[i][e.b], min(d[i-1][e.a],e.w));
			if (d[i][e.b] != INT_MIN)
				d[i][e.a] = max(d[i][e.a], min(d[i-1][e.b],e.w));
		}
	}

	for (int i = 1; i <= n; i++) {
		if (d[h][i] < -1000000) {
			cout << "-1 ";
		} else {
			cout << (i==k?0:d[h][i]) << " ";
		}
	}
	cout << "\n";
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/04ms4868 KiB
2Wrong answer0/06ms9856 KiB
3Wrong answer0/14ms7860 KiB
4Wrong answer0/16ms10248 KiB
5Wrong answer0/27ms12064 KiB
6Wrong answer0/27ms13796 KiB
7Wrong answer0/26ms10720 KiB
8Wrong answer0/26ms10848 KiB
9Wrong answer0/18ms16448 KiB
10Wrong answer0/112ms24664 KiB
11Wrong answer0/114ms28464 KiB
12Wrong answer0/110ms20016 KiB
13Wrong answer0/214ms28460 KiB
14Wrong answer0/214ms25692 KiB
15Wrong answer0/220ms41036 KiB
16Wrong answer0/214ms25788 KiB
17Wrong answer0/217ms33668 KiB
18Wrong answer0/225ms53424 KiB
19Wrong answer0/223ms41324 KiB
20Wrong answer0/217ms33812 KiB
21Runtime error0/130ms62556 KiB
22Runtime error0/129ms62316 KiB
23Runtime error0/130ms62076 KiB
24Runtime error0/130ms62048 KiB
25Runtime error0/230ms61812 KiB
26Runtime error0/235ms61784 KiB
27Runtime error0/232ms61756 KiB
28Runtime error0/235ms61732 KiB
29Runtime error0/235ms61708 KiB
30Runtime error0/230ms61684 KiB
31Runtime error0/235ms61608 KiB
32Runtime error0/235ms61584 KiB