文章
3
粉丝
109
获赞
3
访问
1.6k
#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 return {x, y - 1};
}
int vis[100][100];
int main(){
while(cin >> n >> m){
for(int i = 0; i < n; i ++) cin >> g[i];
int x, y, direction;
for(int i = 0; i < n; i ++){
for(int j = 0; j < m; j ++){
if(g[i][j] == 'L') direction = 3,x = i, y = j;
else if(g[i][j] == 'R') direction = 1,x = i, y = j;
else if(g[i][j] == 'U') direction = 0,x = i, y = j;
else if(g[i][j] == 'D') direction = 2,x = i, y = j;
vis[i][j] = false;
}
}
int ans = 1;
vis[x][y] ++;
while(true)...
登录后发布评论
暂无评论,来抢沙发