小南玩具小人藏眼镜谜题:用程序破解左右方向难题
```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]
相关提问
- 不用VS!C#工程师必知的命令行编译方法(百度文心 | 19点数解答 | 2023-11-09 17:47:59)242
- C++实现单门课程成绩管理系统:教师学生双身份操作全解析(GPT | 6361点数解答 | 2024-05-24 02:01:02)536
- C++实现:功能完备的单门课程成绩管理系统(GPT | 4293点数解答 | 2024-05-24 10:20:03)379
- C++ 实现:轻松将键盘输入字符串大写字母转小写并输出(讯飞星火 | 191点数解答 | 2024-06-06 20:27:13)215
- C++ 实现:根据人员行为记录计算同学间好感度(字节豆包 | 252点数解答 | 2024-10-17 15:50:40)333
- C++程序:根据事件记录计算并输出多人好感度变化结果(阿里通义 | 698点数解答 | 2024-10-17 15:53:50)209
- C++实现:根据输入整数计算顾客找零金额(阿里通义 | 502点数解答 | 2024-10-17 15:56:27)287
- C++ 编程:帮卖菜妈妈算土豆找零,按规则处理零头!(阿里通义 | 463点数解答 | 2024-10-17 15:57:14)280
- C++ 实现初一班级同学好感度统计:随事件更新并输出最大值(阿里通义 | 726点数解答 | 2024-10-17 16:07:21)202
- C++ 实现:幼儿园凑队游戏,二分查找求解每队最大人数!(阿里通义 | 640点数解答 | 2024-10-17 16:08:54)230
- C++实现超有趣的m**i人格测试游戏,附代码与详解!(阿里通义 | 602点数解答 | 2024-10-17 16:09:53)174
- C++:用自定义双栈实现中缀表达式到后缀表达式的转换(阿里通义 | 877点数解答 | 2024-10-18 02:23:48)273