解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class T1429 { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNext()) { int row = in.nextInt(),col = in.nextInt(); int [][]a = new int[row][col]; for(int i = 0;i<row;i++) for(int j = 0;j<col;j++) a[i][j]=in.nextInt(); int x = in.nextInt(),y = in.nextInt(); char dir = in.next().charAt(0); int steps = in.nextInt(); //solve String str = "LURD"; int [][][]t = {{{0,-1},{-1,0},{0,1},{1,0}}, {{0,-1},{-1,0},{0,1},{1,0}}}; int []t2 = {3,1}; while(steps-->0) { dir=str.charAt((str.indexOf(dir)+t2[a[x][y]])%4); a[x][y]=(a[x][y]+1)%2; x+=t[a[x][y]][str.indexOf(dir)][0]; y+=t[a[x][y]][str.indexOf(dir)][1]; } System.out.println(x+" "+y); } in.close(); } }
0.0分
0 人评分