记录详情

Wrong Answer

/in/foo.c: In function 'main':
/in/foo.c:18:3: warning: 'gets' is deprecated [-Wdeprecated-declarations]
   gets(map[i]);
   ^~~~
In file included from /in/foo.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/ccwQAUFt.o: In function `main':
foo.c:(.text.startup+0x38): warning: the `gets' function is dangerous and should not be used.
# 状态 耗时 内存占用
#1 Accepted 1ms 216.0 KiB
#2 Wrong Answer 0ms 220.0 KiB
#3 Accepted 0ms 128.0 KiB
#4 Accepted 0ms 216.0 KiB
#5 Accepted 0ms 208.0 KiB

代码

#include<stdio.h>
#include<stdlib.h>
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define N 10
typedef struct node
{
	int x;
	int y;
	struct node* last;
	struct node* next;
}Node;
typedef Node* LinkList;
int main()
{
	char map[N][N+1] = { 0 };
	rep(i, 0, N-1)
	{
		gets(map[i]);
	}
	/*rep(i, 0, N-1)
	{
		rep(j, 0, N-1)
			printf("%c", map[i][j]);
		printf("\n");
	}*/
	//create a list
	LinkList head = (LinkList)malloc(sizeof(Node));
	head->last = NULL;
	head->x = 0;
	head->y = 0;
	map[0][0] = '0';

	LinkList p = head;
	int flag = 1;
	while (p->x != N-1 && p->y != N-1)
	{
		LinkList pr = (LinkList)malloc(sizeof(Node));
		if (map[p->x + 1][p->y] == '.')
		{
			pr->x = p->x + 1;
			pr->y = p->y;
			p->next = pr;
			pr->last = p;
			p = pr;
			map[pr->x][pr->y] = '0';

		}
		else if (map[p->x][p->y + 1] == '.')
		{
			pr->x = p->x;
			pr->y = p->y + 1;
			p->next = pr;
			pr->last = p;
			p = pr;
			map[pr->x][pr->y] = '0';
		}
		else if (p->y - 1 >= 0 && map[p->x][p->y - 1] == '.')
		{
			pr->x = p->x;
			pr->y = p->y - 1;
			p->next = pr;
			pr->last = p;
			p = pr;
			map[pr->x][pr->y] = '0';
		}
		else if (p->x - 1 >= 0 && map[p->x - 1][p->y] == '.')
		{
			pr->x = p->x - 1;
			pr->y = p->y;
			p->next = pr;
			pr->last = p;
			p = pr;
			map[pr->x][pr->y] = '0';
		}
		else
		{
			p = p->last;
			if (p->x == 0 && p->y == 0)
			{
				flag = 0;
				break;
			}
		}
	}
	if (flag)
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
}

信息

递交者
类型
递交
题目
P1001 hitwh 2019 新生赛 B lxdlam 和他的迷宫
语言
C
递交时间
2020-12-18 11:27:02
评测时间
2020-12-18 11:27:02
评测机
分数
80
总耗时
4ms
峰值内存
220.0 KiB