| Resources | |||||
|---|---|---|---|---|---|
| IUSACO | 本模块基于 Darren Yao 所著书籍的第 5 章 | ||||
由于这里没有涉及正式的算法,这类题旨在考查选手运用所选编程语言的能力,以及对 内置数据结构的了解。至少在 USACO 铜组中,如果题目要求找出某个过程的最终结果, 或某件事情发生的时刻,通常直接模拟该过程就足够了。
示例 1
Focus Problem – try your best to solve this problem before continuing!
解答
我们可以模拟这个过程。用一个数组记录每个位置上是哪只贝壳,通过交换数组中的元素 来模拟 Bessie 的交换操作。接着统计 Elsie 对每只贝壳猜了多少次;某只贝壳被猜中 次数的最大值,就是她能够获得的最高分数。
read = open("shell.in")n = int(read.readline())# shell_at_pos[i] stores the label of the shell located at position i# The shells can be placed arbitrarily at the start.shell_at_pos = [i for i in range(3)]# counter[i] stores the number of times the shell with label i was pickedcounter = [0 for _ in range(3)]
示例 2
Focus Problem – try your best to solve this problem before continuing!
解答
我们可以模拟桶之间倒牛奶的过程。从桶 倒入桶 的牛奶量,等于桶 中 现有牛奶量 与桶 剩余空间 中的较小值。只需按顺序处理所有 操作:用数组 存储每只桶的最大容量,用数组 存储每只桶当前的牛奶量, 并在模拟过程中不断更新 。示例代码如下。
N = 3 # The number of buckets (which is 3)TURN_NUM = 100# capacity[i] is the maximum capacity of bucket icapacity = [0 for _ in range(N)]# milk[i] is the current amount of milk in bucket imilk = [0 for _ in range(N)]with open("mixmilk.in") as read:for i in range(N):capacity[i], milk[i] = map(int, read.readline().split())
题目
较简单
| Status | Source | Problem Name | Difficulty | Tags | ||
|---|---|---|---|---|---|---|
| Bronze | Easy | Show TagsSimulation | ||||
| Bronze | Easy | Show TagsSimulation | ||||
| Bronze | Easy | Show TagsSimulation | ||||
| Bronze | Easy | Show TagsSimulation | ||||
| Bronze | Easy | Show TagsSimulation | ||||
较困难
| Status | Source | Problem Name | Difficulty | Tags | ||
|---|---|---|---|---|---|---|
| Bronze | Medium | Show TagsSimulation | ||||
| Bronze | Medium | Show TagsSimulation | ||||
| Bronze | Medium | Show TagsSimulation | ||||
| Bronze | Medium | Show TagsSimulation | ||||
| Bronze | Medium | Show TagsSimulation | ||||
| Bronze | Medium | Show TagsSimulation | ||||
| Old Bronze | Hard | Show TagsSimulation | ||||
| Bronze | Hard | Show TagsSimulation | ||||
| Bronze | Very Hard | Show TagsSimulation | ||||