解题思路:
注意事项:
参考代码:
def white(mapList, x, y, direction, steps): mapList[x][y] = 1 if direction == "U": y -= 1 direction = "L" elif direction == "D": y += 1 direction = "R" elif direction == "L": x += 1 direction = "D" else: x -= 1 direction = "U" steps -= 1 return mapList, x, y, direction, steps def black(mapList, x, y, direction, steps): mapList[x][y] = 0 if direction == "U": y += 1 direction = "R" elif direction == "D": y -= 1 direction = "L" elif direction == "L": x -= 1 direction = "U" else: x += 1 direction = "D" steps -= 1 return mapList, x, y, direction, steps m, n = map(int, input().strip().split()) mapList = [[int(temp) for temp in input().strip().split()] for i in range(m)] inputList = input().strip().split() x, y = int(inputList[0]), int(inputList[1]) direction = inputList[2] steps = int(inputList[-1]) while steps!=0: if mapList[x][y]==1: mapList, x, y, direction, steps = black(mapList, x, y, direction, steps) else: mapList, x, y, direction, steps = white(mapList, x, y, direction, steps) print(x, y)
0.0分
2 人评分
简单的a+b (C语言代码)浏览:599 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:644 |
C二级辅导-同因查找 (C语言代码)浏览:568 |
简单的a+b (C语言代码)浏览:508 |
C语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:2126 |
哥德巴赫曾猜测 (C++代码)浏览:740 |
WU-震宇大神的杀毒软件 (C++代码)浏览:854 |
银行业务队列浏览:1204 |
最大连续子序列浏览:1014 |
C语言程序设计教程(第三版)课后习题3.7 (C++代码)浏览:635 |