Accepted
/in/foo.cc: In function 'int main()': /in/foo.cc:23:3: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations] gets(c); ^~~~ In file included from /usr/include/c++/6/cstdio:42:0, from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:46, from /in/foo.cc:1: /usr/include/stdio.h:640:14: note: declared here extern char *gets (char *__s) __wur __attribute_deprecated__; ^~~~ /in/foo.cc:23:9: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations] gets(c); ^ In file included from /usr/include/c++/6/cstdio:42:0, from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:46, from /in/foo.cc:1: /usr/include/stdio.h:640:14: note: declared here extern char *gets (char *__s) __wur __attribute_deprecated__; ^~~~ /tmp/ccsRMIfb.o: In function `main': foo.cc:(.text.startup+0x2c): warning: the `gets' function is dangerous and should not be used.
代码
#include<bits/stdc++.h>
using namespace std;
char c[11];
int a[11][11],v[11][11];
int dx[] = {0,0,1,-1},dy[] = {1,-1,0,0};
void dfs(int x,int y){
v[x][y] = 1;
if(x == 10 && y == 10){
printf("Yes\n");
exit(0);
}
for(int i = 0; i < 4; i++){
int nx = x + dx[i],ny = y + dy[i];
if(!a[nx][ny] && nx <= 10 && nx >= 1 && ny <= 10 && ny >= 1 && !v[nx][ny])
{
v[nx][ny] = 1;
dfs(nx,ny);
}
}
}
int main(){
for(int i = 1; i <= 10; i++){
gets(c);
for(int j = 0; j < 10; j++)
if(c[j] == '#') a[i][j + 1] = 1;
}
dfs(1,1);
printf("No\n");
return 0;
}
信息
- 递交者
- 类型
- 递交
- 题目
- P1001 hitwh 2019 新生赛 B lxdlam 和他的迷宫
- 语言
- C++
- 递交时间
- 2020-12-21 14:31:48
- 评测时间
- 2020-12-21 14:31:48
- 评测机
- 分数
- 100
- 总耗时
- 8ms
- 峰值内存
- 228.0 KiB