toj2470



package Toj2470;
import java.util.Scanner;
class Robot {
 public int x;
 public int y;
 public int step;
 public int faceDire;
 public Robot(int x, int y, int step, int faceDire){
  this.x = x;
  this.y = y;
  this.step = step;
  this.faceDire = faceDire;
 }
}
class Queue {
 public Robot[] myRobot = new Robot[100000];
 public int front = 0;
 public int rear = 0;

 public void push(Robot robot) {
  myRobot[rear++] = robot;
 }

 public Robot pop() {
  return myRobot[front++];
 }

 public boolean isEmpty() {
  return front == rear;
 }
}
// 0 up
// 1 right
// 2 down
// 3 left
public class Tojtwo {
 public static int turnOver[] = { 0, 1, 2, -1 };
   
 public static int m;
 public static int n;
 public static int mazeMap[][];
 public static int startx;
 public static int starty;

 public static int endx;
 public static int endy;
    public static int dirx[]={-1,0,1,0};
    public static int diry[]={0,1,0,-1};
 public static void bFS() {
  Robot myRobot = new Robot(startx,starty,0,2);
  Queue myQueue=new Queue();
  myQueue.push(myRobot);
  while(!myQueue.isEmpty()){
   
   Robot curRobot=myQueue.pop();
   int curx=curRobot.x;
   int cury=curRobot.y;
   int curStep=curRobot.step;
   int curFaceDire=curRobot.faceDire;
   
   int nextx;
   int nexty;
   
   
   for(int i=0;i<4;i++){
    nextx=curx+dirx[i];
    nexty=cury+diry[i];
    if(nextx>=0&&nextx<m&&nexty>=0&&nexty<n&&mazeMap[nextx][nexty]==0){
     
     
    }
    
   }
  }
 }

 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  int casenum = sc.nextInt();

  for (int k = 0; k < casenum; k++) {
///
      m = sc.nextInt();
      n = sc.nextInt();
   char maze[][] = new char[m][n];
   mazeMap= new int[m][n];

   String[] str = new String[m];

   for (int i = 0; i < m; i++) {
    str[i] = sc.next();
   }

   for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
     maze[i][j] = str[i].charAt(j);
    }
   }

   for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
     if (maze[i][j] == '#')
      mazeMap[i][j] = 1;
     if (maze[i][j] == '.')
      mazeMap[i][j] = 0;
     if (maze[i][j] == 'S') {
      startx = i;
      starty = j;

      mazeMap[i][j] = 0;
     }
     if (maze[i][j] == 'T') {
      endx = i;
      endy = j;

      mazeMap[i][j] = 0;
     }

    }
   }
///
  }

 }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值