Submission #72548509


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;

int n, m, L, S, T;
int e[N], h[N], ne[N], w[N], idx;
bool ck[N];

void add(int u, int v, int w1){
    e[idx] = v, ne[idx] = h[u], w[idx] = w1, h[u] = idx++;
}

void dfs(int u, int k, ll sum){
    if(sum > T) return;
    if(k == L){
        if(sum >= S && sum <= T){
            ck[u] = 1;
        }
        return;
    }
    for(int i=h[u];~i;i=ne[i]){
        int j = e[i];
        dfs(j, k + 1, sum + (ll)w[i]);
    }
}

int main(){
    memset(h, -1, sizeof h);
    scanf("%d%d%d%d%d", &n, &m, &L, &S, &T);
    for(int i=1;i<=m;i++){
        int u, v, c;
        scanf("%d%d%d", &u, &v, &c);
        add(u, v, c);
    }
    dfs(1, 0, 0);
    bool flag = 0;
    for(int i=1;i<=n;i++){
        if(ck[i]){
            flag = 1;
            printf("%d ", i);
        }
    }
    if(!flag){
        printf("\n");
    }
    return 0;
}

Submission Info

Submission Time
Task D - Paid Walk
User Queryme
Language C++23 (GCC 15.2.0)
Score 400
Code Size 970 Byte
Status AC
Exec Time 44 ms
Memory 7200 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 4540 KiB
example_01.txt AC 1 ms 4568 KiB
example_02.txt AC 1 ms 4576 KiB
hand_00.txt AC 27 ms 6984 KiB
hand_01.txt AC 36 ms 7068 KiB
hand_02.txt AC 32 ms 6880 KiB
hand_03.txt AC 34 ms 7108 KiB
hand_04.txt AC 31 ms 7196 KiB
hand_05.txt AC 24 ms 6924 KiB
hand_06.txt AC 3 ms 4636 KiB
hand_07.txt AC 3 ms 4364 KiB
hand_08.txt AC 29 ms 6984 KiB
hand_09.txt AC 29 ms 6984 KiB
hand_10.txt AC 1 ms 4576 KiB
hand_11.txt AC 1 ms 4768 KiB
hand_12.txt AC 23 ms 6924 KiB
hand_13.txt AC 24 ms 6924 KiB
hand_14.txt AC 21 ms 6940 KiB
hand_15.txt AC 28 ms 7008 KiB
hand_16.txt AC 31 ms 7004 KiB
hand_17.txt AC 29 ms 6924 KiB
hand_18.txt AC 29 ms 6960 KiB
hand_19.txt AC 27 ms 7040 KiB
hand_20.txt AC 29 ms 6880 KiB
hand_21.txt AC 29 ms 7140 KiB
hand_22.txt AC 31 ms 6880 KiB
hand_23.txt AC 40 ms 7116 KiB
random_00.txt AC 27 ms 6876 KiB
random_01.txt AC 26 ms 6912 KiB
random_02.txt AC 27 ms 6988 KiB
random_03.txt AC 27 ms 6880 KiB
random_04.txt AC 26 ms 6844 KiB
random_05.txt AC 27 ms 6984 KiB
random_06.txt AC 27 ms 7008 KiB
random_07.txt AC 28 ms 6876 KiB
random_08.txt AC 27 ms 6924 KiB
random_09.txt AC 26 ms 6816 KiB
random_10.txt AC 27 ms 6876 KiB
random_11.txt AC 28 ms 7200 KiB
random_12.txt AC 27 ms 7040 KiB
random_13.txt AC 34 ms 6916 KiB
random_14.txt AC 34 ms 7040 KiB
random_15.txt AC 34 ms 6976 KiB
random_16.txt AC 27 ms 7012 KiB
random_17.txt AC 44 ms 7200 KiB
random_18.txt AC 27 ms 7196 KiB
random_19.txt AC 30 ms 7112 KiB
random_20.txt AC 27 ms 6984 KiB
random_21.txt AC 27 ms 7012 KiB
random_22.txt AC 27 ms 6844 KiB
random_23.txt AC 32 ms 7068 KiB
random_24.txt AC 27 ms 6988 KiB
random_25.txt AC 26 ms 6836 KiB
random_26.txt AC 26 ms 6924 KiB
random_27.txt AC 27 ms 7016 KiB
random_28.txt AC 27 ms 6844 KiB
random_29.txt AC 26 ms 7072 KiB