Hello, I was trying the problem - The Great Escape [GREATESC]. However, the system is not accepting the code due to some warnings and is showing wrong answer. I am adding the parts of code which I think are relevant and the warning message. Please help in getting it correct. Thank You.
The following are the definitions and some functions for my adjList.
struct adjNode {long dest;struct adjNode* next;};struct adjList {long level;struct ajdNode* head;};struct Graph {long count;struct adjList* list;};struct Graph* createGraph(long count) {struct Graph* graph = (struct Graph*)malloc(sizeof(struct Graph));graph->list = (struct adjList*)malloc(count * sizeof(struct adjList));graph->count = count;long i;for(i=0; i<count; i++) {graph->list[i].head = NULL;graph->list[i].level = max;}return graph;}struct adjNode* createNode(long dest) {struct adjNode* node = (struct adjNode*)malloc(sizeof(struct adjNode));node->dest = dest;node->next = NULL;return node;}void addEdge(struct Graph* graph, long src, long dest) {struct adjNode* node = createNode(dest);node->next = (struct adjNode*)graph->list[src].head;graph->list[src].head = node;node = createNode(src);node->next = graph->list[dest].head;graph->list[dest].head = node;}
These are warnings that I'm getting in the addEdge function.
adjListBfs.c: In function ‘addEdge’:adjListBfs.c:43:24: warning: assignment from incompatible pointer type [enabled by default]graph->list[src].head = node;^adjListBfs.c:46:13: warning: assignment from incompatible pointer type [enabled by default]node->next = graph->list[dest].head;^adjListBfs.c:47:25: warning: assignment from incompatible pointer type [enabled by default]graph->list[dest].head = node;^
Any idea how to get rid of them? The code is running fine and is giving correct output on my machine. However, on submitting it is showing wrong answer and says that the code compiled successfully but gave the above warnings.
EDIT: The code worked. Turns out I was making a mistake in the output. So it has worked for 9 test cases. I'll debug it for the last. Still if anyone has any idea about these warnings then do let me know.