92312024-02-19 10:17:20TuruTamasHálózati átvitelcpp17Time limit exceeded 4/50648ms8608 KiB
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
ifstream in_file("minta/be2.txt");
#define input in_file
#define INTHENAMEOFGOD
#else
#define input cin
#define INTHENAMEOFGOD \
    ios::sync_with_stdio(0); \
    cin.tie(0); \
    cout.tie(0);
#endif
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<ll, ll> pii;

ll N, M, H, K, a, b, c;
vector<vector<pii>> G;
vi s, d;

void dfs(ll x, ll h, ll seb) {
    d[x] = h;
    s[x] = max(s[x], seb);
    if (h == H) {
        return;
    }
    for (pii &next : G[x]) {
        dfs(next.first, h+1, min(seb, next.second));
        // if (s[next.first] < min(next.second, seb)) {
        //     s[next.first] = min(next.second, seb);
        //     dfs(next.first, h+1, min(next.second, seb));
        // }
        // else if (d[next.first] > h+1) {
            
        // } 
    }
}

int main() {
    INTHENAMEOFGOD
    input >> N >> M >> K >> H;
    K--;
    G.resize(N);
    s.assign(N, -1);
    d.assign(N, LLONG_MAX);
    
    for (ll m = 0; m < M; m++) {
        input >> a >> b >> c;
        a--; b--;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }

    dfs(K, 0, LLONG_MAX);
    s[K] = 0;
    

    for (ll val : s) {
        cout << val << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/03ms1892 KiB
2Accepted0/097ms2260 KiB
3Accepted1/13ms2200 KiB
4Accepted1/13ms2420 KiB
5Accepted2/2298ms2776 KiB
6Time limit exceeded0/2555ms1920 KiB
7Time limit exceeded0/2573ms3088 KiB
8Time limit exceeded0/2558ms2040 KiB
9Time limit exceeded0/1573ms2208 KiB
10Time limit exceeded0/1569ms2676 KiB
11Time limit exceeded0/1565ms2884 KiB
12Time limit exceeded0/1560ms3172 KiB
13Time limit exceeded0/2560ms3216 KiB
14Time limit exceeded0/2648ms3500 KiB
15Time limit exceeded0/2569ms3912 KiB
16Time limit exceeded0/2569ms3764 KiB
17Time limit exceeded0/2563ms3892 KiB
18Time limit exceeded0/2580ms4320 KiB
19Time limit exceeded0/2556ms4404 KiB
20Time limit exceeded0/2552ms4504 KiB
21Time limit exceeded0/1569ms4908 KiB
22Time limit exceeded0/1573ms5340 KiB
23Time limit exceeded0/1560ms5764 KiB
24Time limit exceeded0/1569ms6188 KiB
25Time limit exceeded0/2569ms6564 KiB
26Time limit exceeded0/2552ms6880 KiB
27Time limit exceeded0/2646ms7200 KiB
28Time limit exceeded0/2556ms7360 KiB
29Time limit exceeded0/2564ms7684 KiB
30Time limit exceeded0/2648ms7976 KiB
31Time limit exceeded0/2569ms8340 KiB
32Time limit exceeded0/2600ms8608 KiB