Demo entry 6780634

dassad

   

Submitted by anonymous on Dec 27, 2018 at 16:21
Language: C. Code size: 580 Bytes.

int solve(int init, int targets) 
{
	char **visited = malloc(M* sizeof(char*));
	int **mem = malloc(M * sizeof(int*));
	int **next = malloc(M * sizeof(int*));
	for (int i = 0; i < M; i++) 
	{
		visited[i] = calloc(targets + 1, sizeof(char));
		mem[i] = calloc(targets + 1, sizeof(int));
		next[i] = malloc((targets + 1)* sizeof(int));
		for (int j = 0; j < targets + 1; j++)
		{
			next[i][j] = INT_MAX;
		}
	}

	int ret = dfs(init, visited, targets, mem, next);
	printf("path = ");
	print_path(targets,next,0);
	printf("\nresult = %d\n", ret);
	return ret;
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).