酷代码 AI
菜单
服务商

小南玩具小人藏眼镜谜题:用程序破解左右方向难题

```python n, m = map(int, input().split()) # 存储每个玩具小人的朝向和职业 people = [] for _ in range(n): direction, occupation = input().split() people.append((int(direction), occupation)) # 处理指令 current_index = 0 for _ in range(m): left_or_right, step = map(int, input().split()) current_direction = people[current_index][0] # 调整左右方向 if (current_direction == 0 and left_or_right == 0) or (current_direction == 1 and left_or_right == 1): current_index = (current_index + step) % n else: current_index = (current_index - step) % n print(people[current_index][1]) ``` ######[AI问答 | 184点数解答 | 2026-01-24 12:57:27]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]