妈妈生的
2024-01-06 16:45:28
发布于:广东
70阅读
0回复
0点赞
wa了一个,坑定不是我的问题(
#include <iostream>
using namespace std;
int n = 10, m = 10;
char mp[55][55];
bool vis[55][55];
int dir[4][2] = {-1, 0, 0, -1, 0, 1, 1, 0};
bool flag;
bool check(int x, int y){
if(x < 1) return 0;
if(x > n) return 0;
if(y < 1) return 0;
if(y > m) return 0;
if(vis[x][y]) return 0;
if(mp[x][y] == '#') return 0;
return 1;
}
int xz, yz;
void dfs(int x, int y){
if(x == xz && y == yz){
flag = 1;
return;
}
vis[x][y] = 1;
for(int i = 0; i < 4; i++){
int xx = x + dir[i][0];
int yy = y + dir[i][1];
if(check(xx, yy)){
dfs(xx, yy);
}
//vis[xx][yy] = 0;
}
}
int main(){
for(int i = 1; i <= 10; i++){
for(int j = 1; j <= 10; j++){
cin >> mp[i][j];
if(mp[i][j] == '%') xz = i, yz = j;
}
}dfs(1, 1);
if(flag) cout << "欧了";
else cout << "不";
return 0;
}
全部评论 1
这次婴孩没问题了
2024-01-19 来自 浙江
16
2024-01-19 来自 浙江
1byd抄我答案
2024-01-21 来自 广东
1包的呀
2024-09-17 来自 浙江
1
有帮助,赞一个