解题思路:
注意事项:
参考代码:
row, col = map(int, input().split()) map_ = [list(map(int, input().split()))[:col] for _ in range(row)] x, y, head, step = input().split() x, y, step = map(int, (x, y, step)) dic = {'U': {"L": [0, -1], "R": [0, 1]}, 'D': {"L": [0, 1], "R": [0, -1]}, 'L': {"L": [1, 0], "R": [-1, 0]}, 'R': {"L": [-1, 0], "R": [1, 0]}} new_head = {"UL": "L", "UR": "R", "DL": "R", "DR": "L", "LL": "D", "LR": "U", "RL": "U", "RR": "D"} for _ in range(step): # white: 0 -> "L" if map_[x][y] == 1: map_[x][y] = 0 x = x + dic[head]["R"][0] y = y + dic[head]["R"][1] head = new_head[head + "R"] else: map_[x][y] = 1 x = x + dic[head]["L"][0] y = y + dic[head]["L"][1] head = new_head[head + "L"] print(x, y)
0.0分
1 人评分
点我有惊喜!你懂得!浏览:1395 |
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:545 |
A+B for Input-Output Practice (IV) (C语言代码)浏览:517 |
C语言程序设计教程(第三版)课后习题6.11 (C语言代码)for循环浏览:1131 |
WU-字符串比较 (C++代码)浏览:758 |
C语言考试练习题_一元二次方程 (C语言代码)浏览:576 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:1433 |
用筛法求之N内的素数。 (C++代码)浏览:693 |
Hello, world! (C语言代码)浏览:714 |
C二级辅导-温度转换 (C语言代码)浏览:732 |