Submission #72565729


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull=unsigned long long;
const int INF = 1e9;
const long long INFLL = (long long)1e18;
const double PI = acos(-1);
//cout << fixed << setprecision(15) << ans << '\n';

void dfs(const vector<vector<pair<ll,ll>>>& g,ll cur,ll cost,int d,vector<ll>& ans,const ll l,const ll s,const ll t)
{
    if(d==l)
    {
        if(s<=cost and cost<=t)ans[cur]=1;
        return;
    }

    int nex=g[cur].size();
    for(int i=0;i<nex;i++)
    {
        ll next=g[cur][i].first,nextc=g[cur][i].second;
        if(nextc+cost<=t)dfs(g,next,cost+nextc,d+1,ans,l,s,t);
    }
}


int main()
{
    ll n,m,l,s,t;cin>>n>>m>>l>>s>>t;
    vector<vector<pair<ll,ll>>>g(n+1);
    for(int i=0;i<m;i++)
    {
        ll u,v,c;cin>>u>>v>>c;
        g[u].push_back({v,c});
    }
    
    vector<ll>ans(n+1,0);
    dfs(g,1,0,0,ans,l,s,t);

    for(int i=1;i<=n;i++)
    {
        if(ans[i])cout<<i<<" ";
    }
    cout<<endl;
    return 0;
}

Submission Info

Submission Time
Task D - Paid Walk
User maou1
Language C++23 (GCC 15.2.0)
Score 400
Code Size 1052 Byte
Status AC
Exec Time 170 ms
Memory 15848 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 3616 KiB
example_01.txt AC 1 ms 3520 KiB
example_02.txt AC 1 ms 3484 KiB
hand_00.txt AC 119 ms 13948 KiB
hand_01.txt AC 131 ms 13856 KiB
hand_02.txt AC 157 ms 13856 KiB
hand_03.txt AC 159 ms 13948 KiB
hand_04.txt AC 154 ms 13952 KiB
hand_05.txt AC 116 ms 15772 KiB
hand_06.txt AC 6 ms 3672 KiB
hand_07.txt AC 3 ms 3484 KiB
hand_08.txt AC 153 ms 13908 KiB
hand_09.txt AC 151 ms 13948 KiB
hand_10.txt AC 4 ms 9428 KiB
hand_11.txt AC 4 ms 9516 KiB
hand_12.txt AC 116 ms 15848 KiB
hand_13.txt AC 114 ms 15772 KiB
hand_14.txt AC 95 ms 15848 KiB
hand_15.txt AC 122 ms 14408 KiB
hand_16.txt AC 155 ms 13912 KiB
hand_17.txt AC 148 ms 13872 KiB
hand_18.txt AC 140 ms 13892 KiB
hand_19.txt AC 144 ms 13928 KiB
hand_20.txt AC 146 ms 13924 KiB
hand_21.txt AC 138 ms 13848 KiB
hand_22.txt AC 157 ms 13952 KiB
hand_23.txt AC 165 ms 13932 KiB
random_00.txt AC 151 ms 14876 KiB
random_01.txt AC 154 ms 14820 KiB
random_02.txt AC 155 ms 14828 KiB
random_03.txt AC 154 ms 14932 KiB
random_04.txt AC 153 ms 14752 KiB
random_05.txt AC 152 ms 14876 KiB
random_06.txt AC 151 ms 14488 KiB
random_07.txt AC 154 ms 14492 KiB
random_08.txt AC 153 ms 14512 KiB
random_09.txt AC 150 ms 14552 KiB
random_10.txt AC 152 ms 14564 KiB
random_11.txt AC 156 ms 14548 KiB
random_12.txt AC 149 ms 13852 KiB
random_13.txt AC 156 ms 13804 KiB
random_14.txt AC 154 ms 13852 KiB
random_15.txt AC 155 ms 13928 KiB
random_16.txt AC 148 ms 13912 KiB
random_17.txt AC 170 ms 13948 KiB
random_18.txt AC 148 ms 13952 KiB
random_19.txt AC 154 ms 13848 KiB
random_20.txt AC 150 ms 13852 KiB
random_21.txt AC 150 ms 13952 KiB
random_22.txt AC 152 ms 13924 KiB
random_23.txt AC 155 ms 13908 KiB
random_24.txt AC 151 ms 14804 KiB
random_25.txt AC 151 ms 14848 KiB
random_26.txt AC 153 ms 14828 KiB
random_27.txt AC 149 ms 14704 KiB
random_28.txt AC 151 ms 14892 KiB
random_29.txt AC 155 ms 14848 KiB