首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
18132254984
2026年3月14日 13:21
机器人走迷宫 题解:
P1675
回复 0
|
赞 0
|
浏览 27
#include<bits/stdc++.h> using namespace std; char dir[4]={'U','R','D','L'}; const int maxn=15; char mp[maxn][maxn]; int vis[maxn][maxn]; bool move(int x,int y,char loc,int w,int h){//判断能否移动 if(loc=='U'){ &...
uly
2026年3月6日 11:08
机器人走迷宫 题解:
P1675
回复 0
|
赞 3
|
浏览 101
#include <bits/stdc++.h> using namespace std; char rmap[10][10]; int ok_map[10][10]; int w, h; // w=行数, h=列数 int sti, stj; bool go_next(int i, int j, int dir) { if (dir == 1) { // 上 if (i == 0) return false; return (rmap[i-1][j] == '.' && ok_map[i-...
formulaunifyx
2026年2月14日 21:30
机器人走迷宫 题解:模拟
P1675
回复 0
|
赞 2
|
浏览 171
#include<bits/stdc++.h> using namespace std; const int maxn=15; char mpt[maxn][maxn]; int flag[maxn][maxn]; int dir[4][2]={{-1,0},{0,1},{1,0},{0,-1}}; int w,h; int tonum(char temp){ if(temp=='U') return 0; if(temp==...
mamba406
2026年2月2日 13:35
机器人走迷宫 题解:dfs
P1675
回复 0
|
赞 5
|
浏览 230
采用dfs的题解,用bool型标记是否可以转向 #include<iostream> #include<vector> #include<algorithm> #include<map> using namespace std; struct point{ int x,y; point(int _x=0,int _y=0):x(_x),y(_y){} }; int dx[]={-1,0,1,0}; int dy[]={0,1...
jqt
2025年8月28日 15:18
机器人走迷宫 题解:
P1675
回复 0
|
赞 1
|
浏览 722
#include<bits/stdc++.h> using namespace std; char road[11][11]; int vis[11][11]; int w,h; int dir[4][4][2]={ -1,0,0,1,1,0,0,-1, 1,0,0,-1,-1,0,0,1, 0,-1,-1,0,0,1,1,0, 0,1,1,0,0,-1,-1,0, }; struct node{ &n...
小刘啊
2025年3月18日 22:08
机器人走迷宫 题解:
P1675
回复 0
|
赞 11
|
浏览 1.6k
首先分析题意,为迷宫问题但是不同于一般的迷宫,其走不通后会顺时针旋转90°,如何解决这个旋转问题是关键。而经过分析,假设机器人是从L开始(即开始向左走),走不动后旋转顺时针90°变为向上走,同理可推出走的轮回为(左->上->右->下),故我们采用二维数组来表示迷宫,额外定义dx,dy来进行完成移位操作。<<此处需要注意,在二维数组中a[x][y]中向上走表示a[x-1][y]>>故我们只需将位移表示为数组下标的加减即可,按照上述推出的规则构造dx和dy(具体如下代码所示),而利用%4来完成向下走到向左的循环(本质就是改变dx数组的...
202110405235
2025年3月8日 21:02
机器人走迷宫 题解:
P1675
回复 0
|
赞 12
|
浏览 1.0k
#include <stdio.h> #include <string.h> #define MAX_SIZE 10 int w, h; char maze[MAX_SIZE][MAX_SIZE + 1]; // 迷宫数组,加1为了存储字符串结束符'\0' int visited[MAX_SIZE][MAX_SIZE]; // 访问标记数组 // 方向数组,分别对应上、右、下、左 int dx[] = {-1, 0, 1, 0}; int dy[] = {0, 1, 0, -1}; char directions[] = "URD...
202110405235
2025年3月8日 21:01
机器人走迷宫 题解:
P1675
回复 0
|
赞 1
|
浏览 728
#include <stdio.h> #include <string.h> #define MAX_SIZE 10 int w, h; char maze[MAX_SIZE][MAX_SIZE + 1]; // 迷宫数组,加1为了存储字符串结束符'\0' int visited[MAX_SIZE][MAX_SIZE]; // 访问标记数组 // 方向数组,分别对应上、右、下、左 int dx[] = {-1, 0, 1, 0}; int dy[] = {0, 1, 0, -1}; char directions[] ...
takanasi
2024年5月29日 18:54
机器人走迷宫 题解:
P1675
回复 0
|
赞 2
|
浏览 1.2k
#include <bits/stdc++.h> using namespace std; char g[100][100]; int n, m; pair<int,int> get(int x,int y,int direction){ if(direction == 0) return {x - 1,y}; else if(direction == 1) return {x, y + 1}; else if(direction == 2) return {x + 1, y}; else retur...
AlbertTuring
2023年6月29日 10:47
C++简单模拟
P1675
回复 1
|
赞 5
|
浏览 2.1k
简单模拟 #include<iostream> #include<cstring> using namespace std; const int N = 20; char map[N][N]; bool st[N][N]; int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { int n,m; while(cin>>n>>m) { memset(map,'*',siz...
1
2
题目
机器人走迷宫
题解数量
13
发布题解
在线答疑
热门题解
1
机器人走迷宫 题解:
2
机器人走迷宫 题解:
3
机器人走迷宫 题解:dfs
4
C++简单模拟
5
方向导航的BFS
6
机器人走迷宫 题解:
7
机器人走迷宫 题解:模拟
8
机器人走迷宫 题解:
9
机器人走迷宫 题解:
10
C语言解法