92322024-02-19 10:19:37TuruTamasHálózati átvitelcpp17Wrong answer 12/50644ms7068 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]) {
        if (d[next.first] < h && s[next.first] > min(seb, next.second)) {
            continue;
        }
        dfs(next.first, h+1, min(seb, next.second));
    }
}

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
base12/50
1Accepted0/03ms1892 KiB
2Wrong answer0/025ms2252 KiB
3Accepted1/13ms2188 KiB
4Accepted1/13ms2412 KiB
5Wrong answer0/214ms2408 KiB
6Time limit exceeded0/2600ms2660 KiB
7Time limit exceeded0/2569ms3020 KiB
8Time limit exceeded0/2573ms3296 KiB
9Wrong answer0/117ms3512 KiB
10Time limit exceeded0/1600ms2760 KiB
11Time limit exceeded0/1560ms3140 KiB
12Time limit exceeded0/1564ms3304 KiB
13Time limit exceeded0/2569ms3164 KiB
14Time limit exceeded0/2569ms3548 KiB
15Time limit exceeded0/2569ms3832 KiB
16Time limit exceeded0/2564ms4056 KiB
17Time limit exceeded0/2573ms3992 KiB
18Time limit exceeded0/2600ms4100 KiB
19Time limit exceeded0/2569ms3892 KiB
20Time limit exceeded0/2565ms4120 KiB
21Time limit exceeded0/1569ms4276 KiB
22Time limit exceeded0/1644ms4464 KiB
23Time limit exceeded0/1556ms4776 KiB
24Time limit exceeded0/1569ms4876 KiB
25Time limit exceeded0/2554ms4976 KiB
26Time limit exceeded0/2577ms4996 KiB
27Time limit exceeded0/2565ms5168 KiB
28Accepted2/241ms7064 KiB
29Accepted2/248ms7064 KiB
30Accepted2/246ms7060 KiB
31Accepted2/246ms7068 KiB
32Accepted2/250ms7064 KiB