Submission #75022026
Source Code Expand
Copy
#include <stdio.h>int N, M, L, S, T;struct edge_s {int to, cost;};int ec[212345];struct edge_s es[212345][8];char yes[212345];void meow(int node, int score, int left) {if (left <= 0) {if (S <= score && score <= T) yes[node] = 1;} else {int i;for (i = 0; i < ec[node]; i++) {meow(es[node][i].to, score + es[node][i].cost, left - 1);}}}int main(void) {int i;int is_first = 1;if (scanf("%d%d%d%d%d", &N, &M, &L, &S, &T) != 5) return 1;for (i = 0; i < M; i++) {int U, V, C;if (scanf("%d%d%d", &U, &V, &C) != 3) return 1;if (ec[U] >= (int)(sizeof(*es) / sizeof(**es))) {puts("f*ck");return 72;}es[U][ec[U]++] = (struct edge_s){ V, C };}meow(1, 0, L);for (i = 1; i <= N; i++) {if (yes[i]) {printf(" %d" + is_first, i);
#include <stdio.h>
int N, M, L, S, T;
struct edge_s {
int to, cost;
};
int ec[212345];
struct edge_s es[212345][8];
char yes[212345];
void meow(int node, int score, int left) {
if (left <= 0) {
if (S <= score && score <= T) yes[node] = 1;
} else {
int i;
for (i = 0; i < ec[node]; i++) {
meow(es[node][i].to, score + es[node][i].cost, left - 1);
}
}
}
int main(void) {
int i;
int is_first = 1;
if (scanf("%d%d%d%d%d", &N, &M, &L, &S, &T) != 5) return 1;
for (i = 0; i < M; i++) {
int U, V, C;
if (scanf("%d%d%d", &U, &V, &C) != 3) return 1;
if (ec[U] >= (int)(sizeof(*es) / sizeof(**es))) {
puts("f*ck");
return 72;
}
es[U][ec[U]++] = (struct edge_s){ V, C };
}
meow(1, 0, L);
for (i = 1; i <= N; i++) {
if (yes[i]) {
printf(" %d" + is_first, i);
is_first = 0;
}
}
putchar('\n');
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Paid Walk |
| User | mikecat |
| Language | C23 (GCC 14.2.0) |
| Score | 400 |
| Code Size | 896 Byte |
| Status | AC |
| Exec Time | 51 ms |
| Memory | 15304 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| 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 | 0 ms | 1716 KiB |
| example_01.txt | AC | 0 ms | 1616 KiB |
| example_02.txt | AC | 0 ms | 1612 KiB |
| hand_00.txt | AC | 36 ms | 14912 KiB |
| hand_01.txt | AC | 46 ms | 15284 KiB |
| hand_02.txt | AC | 41 ms | 14880 KiB |
| hand_03.txt | AC | 43 ms | 15180 KiB |
| hand_04.txt | AC | 40 ms | 15304 KiB |
| hand_05.txt | AC | 36 ms | 14980 KiB |
| hand_06.txt | AC | 3 ms | 1600 KiB |
| hand_07.txt | AC | 3 ms | 1608 KiB |
| hand_08.txt | AC | 41 ms | 14980 KiB |
| hand_09.txt | AC | 41 ms | 14932 KiB |
| hand_10.txt | AC | 1 ms | 1588 KiB |
| hand_11.txt | AC | 1 ms | 1632 KiB |
| hand_12.txt | AC | 36 ms | 14960 KiB |
| hand_13.txt | AC | 36 ms | 14960 KiB |
| hand_14.txt | AC | 32 ms | 14932 KiB |
| hand_15.txt | AC | 39 ms | 15160 KiB |
| hand_16.txt | AC | 41 ms | 15296 KiB |
| hand_17.txt | AC | 41 ms | 14948 KiB |
| hand_18.txt | AC | 40 ms | 15208 KiB |
| hand_19.txt | AC | 41 ms | 15216 KiB |
| hand_20.txt | AC | 41 ms | 15040 KiB |
| hand_21.txt | AC | 41 ms | 15188 KiB |
| hand_22.txt | AC | 41 ms | 14940 KiB |
| hand_23.txt | AC | 49 ms | 15260 KiB |
| random_00.txt | AC | 39 ms | 14944 KiB |
| random_01.txt | AC | 40 ms | 14948 KiB |
| random_02.txt | AC | 39 ms | 14960 KiB |
| random_03.txt | AC | 39 ms | 14940 KiB |
| random_04.txt | AC | 39 ms | 14928 KiB |
| random_05.txt | AC | 39 ms | 15108 KiB |
| random_06.txt | AC | 39 ms | 15180 KiB |
| random_07.txt | AC | 40 ms | 14928 KiB |
| random_08.txt | AC | 39 ms | 14920 KiB |
| random_09.txt | AC | 39 ms | 14944 KiB |
| random_10.txt | AC | 40 ms | 14920 KiB |
| random_11.txt | AC | 41 ms | 15160 KiB |
| random_12.txt | AC | 38 ms | 15304 KiB |
| random_13.txt | AC | 42 ms | 14948 KiB |
| random_14.txt | AC | 44 ms | 15180 KiB |
| random_15.txt | AC | 43 ms | 14912 KiB |
| random_16.txt | AC | 42 ms | 14876 KiB |
| random_17.txt | AC | 51 ms | 15180 KiB |
| random_18.txt | AC | 39 ms | 15172 KiB |
| random_19.txt | AC | 42 ms | 15176 KiB |
| random_20.txt | AC | 42 ms | 14944 KiB |
| random_21.txt | AC | 39 ms | 14876 KiB |
| random_22.txt | AC | 41 ms | 14952 KiB |
| random_23.txt | AC | 44 ms | 15208 KiB |
| random_24.txt | AC | 40 ms | 14932 KiB |
| random_25.txt | AC | 39 ms | 15176 KiB |
| random_26.txt | AC | 40 ms | 14940 KiB |
| random_27.txt | AC | 39 ms | 14928 KiB |
| random_28.txt | AC | 40 ms | 14876 KiB |
| random_29.txt | AC | 39 ms | 14940 KiB |