Submission #72535762


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fix(x) fixed << setprecision(x)
#define rep(i, start, end) for (auto i = (start); (i) < (end); (i)++)
#define repe(i, start, end) for (auto i = (start); (i) <= (end); (i)++)
#define rrep(i, start, end) for (auto i = (start); (i) >= (end); (i)--)

constexpr auto PI = 3.14159265358979;
constexpr int INF = 1e+9;
constexpr long long INFL = 1e+18;

using ll = long long;
using lld = long double;
// using mint = modint1000000007;
using mint = modint998244353;
using Pair_int = pair<int, int>;
using Pair_ll = pair<ll, ll>;
template <class T>
using Graph = vector<vector<T>>;

template <class T1, class T2>
inline auto div_floor(T1 a, T2 b)
{
    if (b < 0)
        a *= -1, b *= -1;
    if (a >= 0)
        return a / b;
    else
        return (a + 1) / b - 1;
}
template <class T1, class T2>
inline auto div_ceil(T1 a, T2 b)
{
    if (b < 0)
        a *= -1, b *= -1;
    if (a <= 0)
        return a / b;
    else
        return (a - 1) / b + 1;
}
ll floor_sqrt(ll x)
{
    ll y = sqrt(x);
    while (y * y > x)
        y--;
    while ((y + 1) * (y + 1) <= x)
        y++;
    return y;
}
ll pow_int(ll x, ll n)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res *= x;
        x *= x;
        n >>= 1;
    }
    return res;
}
ll pow_mod(ll x, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
ll gcd(ll x, ll y)
{
    if (x < y)
        swap(x, y);
    ll r;
    while (y > 0)
    {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}
ll lcm(ll x, ll y) { return ll(x / gcd(x, y)) * y; }
ll nCk(ll n, ll r)
{
    if (r < 0 || n < r)
        return 0;
    ll ans = 1;
    for (ll i = 1; i <= r; i++)
    {
        ans *= n--;
        ans /= i;
    }
    return ans;
}
int get_rand(int seed, int min, int max)
{
    static mt19937_64 mt64(seed);
    uniform_int_distribution<int> get_rand_int(min, max);
    return get_rand_int(mt64);
}
template <typename T>
inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template <typename T>
inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }
template <class T1, class T2>
inline auto mod(T1 x, T2 r) { return (x % r + r) % r; }

// ======================================== //

struct Edge
{
    int to, cost;
};

int main()
{
    int N, M, L, S, T;
    cin >> N >> M >> L >> S >> T;
    Graph<Edge> G(N);
    rep(i, 0, M)
    {
        int U, V, C;
        cin >> U >> V >> C;
        U--, V--;
        G[U].push_back({V, C});
    }

    vector<bool> flag(N, false);
    auto dfs = [&](auto &&self, int now, int l, ll total_cost) -> void
    {
        if (l == L)
        {
            if (S <= total_cost && total_cost <= T)
            {
                flag[now] = true;
            }
            return;
        }

        for (auto &&edge : G[now])
        {
            self(self, edge.to, l + 1, total_cost + edge.cost);
        }
    };

    dfs(dfs, 0, 0, 0);

    rep(i, 0, N)
    {
        if (flag[i])
            cout << i + 1 << ' ';
    }

    return 0;
}

Submission Info

Submission Time
Task D - Paid Walk
User Yuulis
Language C++23 (GCC 15.2.0)
Score 400
Code Size 3353 Byte
Status AC
Exec Time 136 ms
Memory 14260 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 57
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, hand_17.txt, hand_18.txt, hand_19.txt, hand_20.txt, hand_21.txt, hand_22.txt, hand_23.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3408 KiB
example_01.txt AC 1 ms 3580 KiB
example_02.txt AC 1 ms 3496 KiB
hand_00.txt AC 98 ms 10696 KiB
hand_01.txt AC 107 ms 10684 KiB
hand_02.txt AC 131 ms 10640 KiB
hand_03.txt AC 128 ms 10684 KiB
hand_04.txt AC 123 ms 10676 KiB
hand_05.txt AC 98 ms 14260 KiB
hand_06.txt AC 4 ms 3496 KiB
hand_07.txt AC 3 ms 3408 KiB
hand_08.txt AC 127 ms 10676 KiB
hand_09.txt AC 124 ms 10640 KiB
hand_10.txt AC 3 ms 7952 KiB
hand_11.txt AC 3 ms 7884 KiB
hand_12.txt AC 102 ms 14224 KiB
hand_13.txt AC 101 ms 14232 KiB
hand_14.txt AC 76 ms 14168 KiB
hand_15.txt AC 99 ms 11668 KiB
hand_16.txt AC 126 ms 10644 KiB
hand_17.txt AC 119 ms 10684 KiB
hand_18.txt AC 116 ms 10680 KiB
hand_19.txt AC 124 ms 10644 KiB
hand_20.txt AC 120 ms 10676 KiB
hand_21.txt AC 113 ms 10584 KiB
hand_22.txt AC 124 ms 10684 KiB
hand_23.txt AC 132 ms 10640 KiB
random_00.txt AC 127 ms 12096 KiB
random_01.txt AC 132 ms 12212 KiB
random_02.txt AC 129 ms 12180 KiB
random_03.txt AC 123 ms 12100 KiB
random_04.txt AC 121 ms 12212 KiB
random_05.txt AC 123 ms 12212 KiB
random_06.txt AC 126 ms 11632 KiB
random_07.txt AC 129 ms 11608 KiB
random_08.txt AC 127 ms 11648 KiB
random_09.txt AC 121 ms 11668 KiB
random_10.txt AC 123 ms 11700 KiB
random_11.txt AC 124 ms 11608 KiB
random_12.txt AC 123 ms 10640 KiB
random_13.txt AC 126 ms 10704 KiB
random_14.txt AC 128 ms 10676 KiB
random_15.txt AC 122 ms 10640 KiB
random_16.txt AC 126 ms 10676 KiB
random_17.txt AC 136 ms 10560 KiB
random_18.txt AC 120 ms 10572 KiB
random_19.txt AC 124 ms 10680 KiB
random_20.txt AC 120 ms 10684 KiB
random_21.txt AC 120 ms 10624 KiB
random_22.txt AC 123 ms 10676 KiB
random_23.txt AC 125 ms 10640 KiB
random_24.txt AC 127 ms 12176 KiB
random_25.txt AC 123 ms 12096 KiB
random_26.txt AC 121 ms 12176 KiB
random_27.txt AC 124 ms 12212 KiB
random_28.txt AC 126 ms 12220 KiB
random_29.txt AC 128 ms 12176 KiB