Submission #45738766


Source Code Expand

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int N, M;
char* visited;

void dfs(int node, int parent) {
	char buffer[32];
	int k, i;
	int* edges;
	visited[node] = 1;
	if (scanf("%31s", buffer) != 1) exit(1);
	if (strcmp(buffer, "OK") == 0) exit(0);
	if (sscanf(buffer, "%d", &k) != 1) exit(1);
	edges = malloc(sizeof(*edges) * k);
	if (edges == NULL) exit(2);
	for (i = 0; i < k; i++) {
		if (scanf("%d", &edges[i]) != 1) exit(1);
	}
	for (i = 0; i < k; i++) {
		if (!visited[edges[i]]) {
			printf("%d\n", edges[i]);
			fflush(stdout);
			dfs(edges[i], node);
		}
	}
	free(edges);
	printf("%d\n", parent);
	fflush(stdout);
}

int main(void) {
	if (scanf("%d%d", &N, &M) != 2) return 1;
	visited = calloc(N + 1, sizeof(*visited));
	if (visited == NULL) return 2;
	dfs(1, 0);
	return 0;
}

Submission Info

Submission Time
Task F - Dungeon Explore
User mikecat
Language C (gcc 12.2.0)
Score 0
Code Size 842 Byte
Status RE
Exec Time 5 ms
Memory 3976 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 525
Status
AC × 1
AC × 21
WA × 6
RE × 6
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 2 ms 3684 KiB
01_random_01.txt AC 3 ms 3672 KiB
01_random_02.txt AC 3 ms 3640 KiB
01_random_03.txt RE 2 ms 3852 KiB
01_random_04.txt WA 3 ms 3660 KiB
01_random_05.txt AC 2 ms 3792 KiB
01_random_06.txt AC 2 ms 3796 KiB
01_random_07.txt AC 3 ms 3804 KiB
01_random_08.txt WA 3 ms 3648 KiB
01_random_09.txt AC 2 ms 3824 KiB
01_random_10.txt RE 2 ms 3676 KiB
01_random_11.txt RE 2 ms 3748 KiB
01_random_12.txt RE 2 ms 3616 KiB
01_random_13.txt AC 3 ms 3800 KiB
01_random_14.txt AC 4 ms 3976 KiB
01_random_15.txt AC 5 ms 3784 KiB
01_random_16.txt AC 4 ms 3760 KiB
01_random_17.txt AC 3 ms 3736 KiB
01_random_18.txt AC 2 ms 3880 KiB
01_random_19.txt WA 2 ms 3780 KiB
01_random_20.txt WA 2 ms 3680 KiB
01_random_21.txt AC 2 ms 3868 KiB
01_random_22.txt AC 2 ms 3764 KiB
01_random_23.txt WA 3 ms 3648 KiB
01_random_24.txt WA 2 ms 3756 KiB
01_random_25.txt AC 2 ms 3784 KiB
01_random_26.txt AC 2 ms 3728 KiB
01_random_27.txt RE 2 ms 3632 KiB
01_random_28.txt RE 3 ms 3800 KiB
01_random_29.txt AC 5 ms 3796 KiB
01_random_30.txt AC 5 ms 3808 KiB
01_random_31.txt AC 5 ms 3936 KiB
01_random_32.txt AC 5 ms 3904 KiB