Kevin234


私信TA

用户名:Kevin234

访问量:18899

签 名:

手可摘星辰

等  级
排  名 867
经  验 3452
参赛次数 0
文章发表 40
年  龄 0
在职情况 学生
学  校 南京信息工程大学
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区