解题思路:
注意事项:
参考代码:
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 人评分