Submission #72557170


Source Code Expand

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

using ll=long long;
using ull=unsigned long long;

ll N, M, L, S, T;
vector<vector<pair<ll, ll>>> G;
set<int> ans;

void dfs(int u, ll sum, int cnt){
    if(T<sum)return;
    if(cnt==L){
        if(S<=sum&&sum<=T)ans.insert(u);
        return;
    }
    for(auto [v, c]:G[u]){
        dfs(v, sum+c, cnt+1);
    }
}

void solve(){
    cin>>N>>M>>L>>S>>T;
    G.resize(N);
    for(int i=0; i<M; ++i){
        int u, v, c; cin>>u>>v>>c;
        u--; v--;
        G[u].push_back({v,c});
    }

    dfs(0, 0, 0);
    for(int u:ans)cout<<u+1<<" ";
    cout<<endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //cout<<fixed<<setprecision(17);
    int T=1; //cin>>T;
    while(T--)solve();
    return 0;
}

Submission Info

Submission Time
Task D - Paid Walk
User Aseteyan
Language C++23 (GCC 15.2.0)
Score 400
Code Size 834 Byte
Status AC
Exec Time 153 ms
Memory 21460 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 3624 KiB
example_01.txt AC 1 ms 3480 KiB
example_02.txt AC 1 ms 3432 KiB
hand_00.txt AC 44 ms 12328 KiB
hand_01.txt AC 130 ms 21460 KiB
hand_02.txt AC 49 ms 12404 KiB
hand_03.txt AC 67 ms 14612 KiB
hand_04.txt AC 54 ms 13008 KiB
hand_05.txt AC 40 ms 14348 KiB
hand_06.txt AC 5 ms 3472 KiB
hand_07.txt AC 3 ms 3536 KiB
hand_08.txt AC 49 ms 12536 KiB
hand_09.txt AC 49 ms 12368 KiB
hand_10.txt AC 3 ms 8020 KiB
hand_11.txt AC 3 ms 8048 KiB
hand_12.txt AC 41 ms 14460 KiB
hand_13.txt AC 39 ms 14220 KiB
hand_14.txt AC 38 ms 14356 KiB
hand_15.txt AC 60 ms 15644 KiB
hand_16.txt AC 58 ms 13980 KiB
hand_17.txt AC 48 ms 12348 KiB
hand_18.txt AC 59 ms 12368 KiB
hand_19.txt AC 45 ms 12372 KiB
hand_20.txt AC 46 ms 12444 KiB
hand_21.txt AC 46 ms 12356 KiB
hand_22.txt AC 50 ms 12276 KiB
hand_23.txt AC 132 ms 21456 KiB
random_00.txt AC 44 ms 13248 KiB
random_01.txt AC 46 ms 13332 KiB
random_02.txt AC 47 ms 13296 KiB
random_03.txt AC 46 ms 13184 KiB
random_04.txt AC 46 ms 13224 KiB
random_05.txt AC 45 ms 13428 KiB
random_06.txt AC 46 ms 13024 KiB
random_07.txt AC 48 ms 12948 KiB
random_08.txt AC 45 ms 12968 KiB
random_09.txt AC 46 ms 13048 KiB
random_10.txt AC 46 ms 13084 KiB
random_11.txt AC 49 ms 13168 KiB
random_12.txt AC 46 ms 12532 KiB
random_13.txt AC 50 ms 12384 KiB
random_14.txt AC 53 ms 12820 KiB
random_15.txt AC 51 ms 12400 KiB
random_16.txt AC 44 ms 12316 KiB
random_17.txt AC 153 ms 15996 KiB
random_18.txt AC 43 ms 12328 KiB
random_19.txt AC 67 ms 12380 KiB
random_20.txt AC 43 ms 12400 KiB
random_21.txt AC 43 ms 12400 KiB
random_22.txt AC 44 ms 12300 KiB
random_23.txt AC 79 ms 12428 KiB
random_24.txt AC 46 ms 13300 KiB
random_25.txt AC 47 ms 13188 KiB
random_26.txt AC 48 ms 13304 KiB
random_27.txt AC 45 ms 13204 KiB
random_28.txt AC 45 ms 13232 KiB
random_29.txt AC 44 ms 13188 KiB