USACO2023年2月美国计算机奥赛竞赛金奖组问题三——Piling Papers

Farmer John wrote down N (1≤N≤300) digits on pieces of paper. For each i∈[1,N], the ith piece of paper contains digit ai (1≤ai≤9).

The cows have two favorite integers A and B (1≤A≤B<1018), and would like you to answer Q (1≤Q≤5⋅104) queries. For the ith query, the cows will move left to right across papers li…ri (1≤li≤ri≤N), maintaining an initially empty pile of papers. For each paper, they will either add it to the top of the pile, to the bottom of the pile, or neither. In the end, they will read the papers in the pile from top to bottom, forming an integer. Over all 3ri−li+1 ways for the cows to make choices during this process, count the number of ways that result in the cows reading an integer in [A,B] inclusive, and output this number modulo 109+7.

INPUT FORMAT (input arrives from the terminal / stdin):

The first line contains three space-separated integers N, A, and B.

The second line contains N space-separated digits a1,a2,…,aN.

The third line contains an integer Q, the number of queries.

The next Q lines each contain two space-separated integers li and ri.

OUTPUT FORMAT (print output to the terminal / stdout):

For each query, a single line containing the answer.

SAMPLE INPUT:

5 13 327
1 2 3 4 5
3
1 2
1 3
2 5

SAMPLE OUTPUT:

2
18
34
For the first query, there are nine ways Bessie can stack papers when reading the interval [1,2]:

Bessie can ignore 1 then ignore 2, getting 0.
Bessie can ignore 1 then add 2 to the top of the stack, getting 2.
Bessie can ignore 1 then add 2 to the bottom of the stack, getting 2.
Bessie can add 1 to the top of the stack then ignore 2, getting 1.
Bessie can add 1 to the top of the stack then add 2 to the top of the stack, getting 21.
Bessie can add 1 to the top of the stack then add 2 to the bottom of the stack, getting 12.
Bessie can add 1 to the bottom of the stack then ignore 2, getting 1.
Bessie can add 1 to the bottom of the stack then add 2 to the top of the stack, getting 21.
Bessie can add 1 to the bottom of the stack then add 2 to the bottom of the stack, getting 12.
Only the 2 ways that give 21 yield a number between 13 and 327, so the answer is 2.

SCORING:

Inputs 2-3: B<100
Inputs 4-5: A=B
Inputs 6-13: No additional constraints.
Problem credits: Jesse Choe

USACO2023年2月美国计算机奥赛竞赛金奖组问题二——Fertilizing Pastures

There are N pastures (2≤N≤2⋅105), connected by N−1 roads, such that they form a tree. Every road takes 1 second to cross. Each pasture starts out with 0 grass, and the ith pasture's grass grows at a rate of ai (1≤ai≤108) units per second. Farmer John is in pasture 1 at the start, and needs to drive around and fertilize the grass in every pasture. If he visits a pasture with x units of grass, it will need x amount of fertilizer. A pasture only needs to be fertilized the first time it is visited, and fertilizing a pasture takes 0 time.

The input contains an additional parameter T∈{0,1}.

If T=0, Farmer John must end at pasture 1.
If T=1, Farmer John may end at any pasture.
Compute the minimum amount of time it will take to fertilize every pasture and the minimum amount of fertilizer needed to finish in that amount of time.

INPUT FORMAT (input arrives from the terminal / stdin):

The first line contains N and T.
Then for each i from 2 to N, there is a line containing pi and ai, meaning that there is a road connecting pastures pi and i. It is guaranteed that 1≤pi<i.

OUTPUT FORMAT (print output to the terminal / stdout):

The minimum amount of time and the minimum amount of fertilizer, separated by spaces.

SAMPLE INPUT:

5 0
1 1
1 2
3 1
3 4

SAMPLE OUTPUT:

8 21
The optimal route for Farmer John is as follows:

At time 1, move to node 3, which now has 1⋅2=2 grass and so needs 2 fertilizer.
At time 2, move to node 5, which now has 2⋅4=8 grass and so needs 8 fertilizer.
At time 3, move back to node 3, which we already fertilized and so don't need to fertilize again.
At time 4, move to node 4, which now has 4⋅1=4 grass and so needs 4 fertilizer.
At time 5, move back to node 3, which we already fertilized.
At time 6, move back to node 1.
At time 7, move to node 2, which now has 7⋅1=7 grass and so needs 7 fertilizer.
At time 8, return to node 1.
This route takes 8 time and uses 2+8+4+7=21 fertilizer. It can be shown that 8 is the least possible amount of time for any route that returns to node 1 at the end and 21 is the least possible fertilizer used for any route that returns to node 1 and takes 8 time.

SAMPLE INPUT:

5 1
1 1
1 2
3 1
3 4

SAMPLE OUTPUT:

6 29
The optimal route for Farmer John is as follows:

At time 1, move to node 2, which now has 1⋅1=1 grass and so needs 1 fertilizer.
At time 2, move back to node 1.
At time 3, move to node 3, which now has 3⋅2=6 grass and so needs 6 fertilizer.
At time 4, move to node 5, which now has 4⋅4=16 grass and so needs 16 fertilizer.
At time 5, move back to node 3, which we already fertilized and so don't need to fertilize again.
At time 6, move to node 4, which now has 6⋅1=6 grass and so needs 6 fertilizer.
This route takes 6 time and uses 1+6+16+6=29 fertilizer. It can be shown that 6 is the least possible amount of time for any route and 29 is the least possible fertilizer used for any route that takes 6 time.

SCORING:

Inputs 3-10: T=0
Inputs 11-22: T=1
Inputs 3-6 and 11-14: No pasture is adjacent to more than three roads.
Problem credits: Rohin Garg

USACO2023年2月美国计算机奥赛竞赛金奖组问题一——Equal Sum Subarrays

Note: The time limit for this problem is 3s, 1.5x the default.

FJ gave Bessie an array a of length N (2≤N≤500,−1015≤ai≤1015) with all N(N+1)2 contiguous subarray sums distinct. For each index i∈[1,N], help Bessie compute the minimum amount it suffices to change ai by so that there are two different contiguous subarrays of a with equal sum.

INPUT FORMAT (input arrives from the terminal / stdin):

The first line contains N.
The next line contains a1,…,aN (the elements of a, in order).

OUTPUT FORMAT (print output to the terminal / stdout):

One line for each index i∈[1,N].

SAMPLE INPUT:

2
2 -3

SAMPLE OUTPUT:

2
3
Decreasing a1 by 2 would result in a1+a2=a2. Similarly, increasing a2 by 3 would result in a1+a2=a1.

SAMPLE INPUT:

3
3 -10 4

SAMPLE OUTPUT:

1
6
1
Increasing a1 or decreasing a3 by 1 would result in a1=a3. Increasing a2 by 6 would result in a1=a1+a2+a3.

SCORING:

Input 3: N≤40
Input 4: N≤80
Inputs 5-7: N≤200
Inputs 8-16: No additional constraints.
Problem credits: Benjamin Qi

USACO2023年2月美国计算机奥赛竞赛白金奖组问题3——Watching Cowflix

Note: The time limit for this problem is 3s, 1.5x the default.

Bessie likes to watch shows on Cowflix, and she watches them in different places. Farmer John's farm can be represented as a tree with N (2≤N≤2⋅105) nodes, and for each node, either Bessie watches Cowflix there or she doesn't. It is guaranteed that Bessie watches Cowflix in at least one node.

Unfortunately, Cowflix is introducing a new subscription model to combat password sharing. In their new model, you can choose a connected component of size d in the farm, and then you need to pay d+k moonies for an account that you can use in that connected component. Formally, you need to choose a set of disjoint connected components c1,c2,…,cC so that every node where Bessie watches Cowflix must be contained within some ci. The cost of the set of components is ∑Ci=1(|ci|+k), where |ci| is the number of nodes in component ci. Nodes where Bessie does not watch Cowflix do not have to be in any ci.

Bessie is worried that the new subscription model may be too expensive for her given all the places she visits and is thinking of switching to Mooloo. To aid her decision-making, calculate the minimum amount she would need to pay to Cowflix to maintain her viewing habits. Because Cowflix has not announced the value of k, calculate it for all integer values of k from 1 to N.

INPUT FORMAT (input arrives from the terminal / stdin):

The first line contains N.
The second line contains a bit string s1s2s3…sN where si=1 if Bessie watches Cowflix at node i.

Then N−1 lines follow, each containing two integers a and b (1≤a,b≤N), which denotes an edge between a and b in the tree.

OUTPUT FORMAT (print output to the terminal / stdout):

The answers for each k from 1 to N on separate lines.

SAMPLE INPUT:

5
10001
1 2
2 3
3 4
4 5

SAMPLE OUTPUT:

4
6
8
9
10
For k≤3, it's optimal to have two accounts: c1={1},c2={5}. For k≥3, it's optimal to have one account: c1={1,2,3,4,5}.

SAMPLE INPUT:

7
0001010
7 4
5 6
7 2
5 1
6 3
2 5

SAMPLE OUTPUT:

4
6
8
9
10
11
12

SCORING:

Inputs 3-5: N≤5000
Inputs 6-8: i is connected to i+1 for all i∈[1,N).
Inputs 9-19: N≤105
Inputs 20-24: No additional constraints.
Problem credits: Danny Mittal

USACO2023年2月美国计算机奥赛竞赛白金奖组问题二——Problem Setting

Note: The memory limit for this problem is 512MB, twice the default.

Farmer John created N (1≤N≤105) problems. He then recruited M (1≤M≤20) test-solvers, each of which rated every problem as "easy" or "hard."

His goal is now to create a problemset arranged in increasing order of difficulty, consisting of some subset of his N problems arranged in some order. There must exist no pair of problems such that some test-solver thinks the problem later in the order is easy but the problem earlier in the order is hard.

Count the number of distinct nonempty problemsets he can form, modulo 109+7.

INPUT FORMAT (input arrives from the terminal / stdin):

The first line contains N and M.
The next M lines each contain a string of length N. The ith character of this string is E if the test-solver thinks the ith problem is easy, or H otherwise.

OUTPUT FORMAT (print output to the terminal / stdout):

The number of distinct problemsets FJ can form, modulo 109+7.

SAMPLE INPUT:
3 1
EHE

SAMPLE OUTPUT:
9
The nine possible problemsets are as follows:

[1]
[1,2]
[1,3]
[1,3,2]
[2]
[3]
[3,1]
[3,2]
[3,1,2]
Note that the order of the problems within the problemset matters.

SAMPLE INPUT:

10 6
EHEEEHHEEH
EHHHEEHHHE
EHEHEHEEHH
HEHEEEHEEE
HHEEHEEEHE
EHHEEEEEHE

SAMPLE OUTPUT:
33
SCORING:
Inputs 3-4: M=1
Inputs 5-14: M≤16
Inputs 15-22: No additional constraints.
Problem credits: Benjamin Qi

USACO2023年2月美国计算机奥赛竞赛白金奖组问题一——Hungry Cow

Note: The time limit for this problem is 6s, three times the default. The memory limit for this problem is 512MB, twice the default.

Bessie is a hungry cow. Each day, for dinner, if there is a haybale in the barn, she will eat one haybale. Farmer John does not want Bessie to starve, so some days he sends a delivery of haybales, which arrive in the morning (before dinner). In particular, on day di, Farmer John sends a delivery of bi haybales (1≤di≤1014, 0≤bi≤109).

Process U (1≤U≤105) updates as follows: Given a pair (d,b), update the number of haybales arriving on day d to b. After each update, output the sum of all days on which Bessie eats haybales modulo 109+7.

INPUT FORMAT (input arrives from the terminal / stdin):

U, followed by U lines containing the updates.

OUTPUT FORMAT (print output to the terminal / stdout):

The sum after each update modulo 109+7.

SAMPLE INPUT:

3
4 3
1 5
1 2

SAMPLE OUTPUT:

15
36
18
Answers after each update:

4+5+6=15
1+2+3+4+5+6+7+8=36
1+2+4+5+6=18

SAMPLE INPUT:

9
1 89
30 7
101 26
1 24
5 1
60 4
5 10
101 0
1 200

SAMPLE OUTPUT:

4005
4656
7607
3482
3507
3753
4058
1107
24531

SCORING:

Input 3: U≤5000
Inputs 4-10: Updates only increase the number of haybales arriving on day d.
Inputs 11-22: No additional constraints.
Problem credits: Brandon Wang and Benjamin Qi

usaco竞赛每道题多少分,USACO比赛分数是如何计算的?

usaco学术活动每道题多少分?USACO是一项在线编程学术活动,参赛者可以在官方网站注册,并在比赛开放期间参加。每场比赛需要完成3-4个小时,参赛者可以无限次在比赛时间内提交代码。

比赛采用等级积分晋级制,每次比赛需要完成3-4道编程大题,每道题目包含至少10组测试数据,总分值为1000分,分配方式是平均分配到每个测试案例中。一般而言,获得750分及以上的成绩可以晋级。

分数结构:

所有3个编程问题的分值都是333.333分,总分是1000分。对于每个问题,分数在每个测试案例中平均分配。如果问题1有10个测试案例,问题2有11个,问题3有12个测试案例,那么问题1的每个测试案例价值33.33分,问题2的每个测试案例价值30分,而问题3的每个测试案例价值27.77分。

参赛者需要为每道编程大题编写3-4个程序来测试至少10个以上的测试案例,为每个正确的测试用例获取学分。在比赛中,同一类别的所有问题总共有1000分。若程序运行时间过长、内存占用过多或崩溃,可能会损失测试用例分数,因此编写高效的代码非常重要,这在Silver及以上级别的赛组中尤其重要。

如果测试用例失败,可能有以下原因:

T:超时(在Java和Python中为4秒,在其他语言中为2秒);

!:运行时错误(典型的运行时错误,但也包括内存不足);

X:错误答案(你对测试案例的答案是不正确的)。

请扫码可免费获取学术活动真题及资料

USACO是一项需要极强逻辑思维和编程水平的理科学术活动。

虽然该赛事面向全世界招募参赛学生,但成功入围公开赛的人数非常有限,决赛的名额更是寥寥无几。USACO 12月考试是一年中最容易的一次,12月的月赛通常是圣诞前的一个周末,当场出成绩,一周内放榜,也非常适合在RD的截止前冲击申请材料的最后一个闪光点。1,2月份的成绩也可以作为申请递交完毕最好的补充材料。

参赛者应该抓住机会,认真备战。考试形式和考题难度每年都可能发生变化,因此要密切关注学术活动官方信息。

usaco竞赛得奖有证书么?晋级规则是什么?

usaco学术活动得奖有证书么?USACO学术活动没有颁发奖牌和证书,但选手们可以在网站上查看自己的当前成绩和组别。

美国计算机奥林匹克学术活动(USACO)是一项针对全球高中信息学学术活动选手的学术活动,旨在选拔每年夏季举办的国际信息学学术活动(IOI)的美国代表队员。该赛事相当于中国的NOI系列赛,参与者既可以增加学术活动经验,又有机会获得高含金量的信息学成绩。

晋级规则很简单,就是铜-银-金-白金一路升级。USACO学术活动有四个级别,分别为青铜、白银、黄金、白金四个级别,一开始注册账号即为铜级,在比赛中逐渐提高自己的等级,如果最终能够获得黄金或白金级别的奖项,将提高竞争力。

如果选手实力足够强,可以短时间内连续升级。例如,在比赛时间内获得高分数,系统会提示直接晋级,然后在接下来的几天里继续挑战下一个组别。失败的选手需要等待官方公布的晋级分数线,一旦成功晋级,则可以在一个月后的下一场比赛中继续晋级。如果未晋级,则需要等到下一个月的比赛开始再次参赛。

USACO比赛面向5-12年级孩子,无国籍要求,只需在官网上注册成功并具备编程语言基础。比赛可使用的计算机语言包括C++11、Java、C++、Python 3.4.0、Python 2.7.6、C和Pascal。因此,如果同学们对自己的计算机语言有信心,并具备较好的逻辑和理科思维能力,则可以参加比赛。参加USACO比赛无需任何报名费。

USACO主要是在线解题,衡量算法和运用两大方面的技能,旨在锻炼学生用计算机编程解决问题的能力。此外,优异的学术活动成绩还能为学生申请实习加分,因为有些编程题与谷歌、Facebook等科技公司的面试题类似。因此,USACO学术活动不仅能够培养学生的算法和编程思维,而且还有助于学生以后申请实习等方面的发展。

USACO学术活动除了为参赛者提供了一次锻炼编程能力的宝贵机会外,还有一些其他的好处。比如,参赛者将拥有一个由专业裁判组成的评审小组进行评分的机会,以及与来自世界各地的有才华的程序员竞争的机会。此外,获得USACO奖项和资格还可以作为加入计算机俱乐部或公司、为学术和职业生涯做准备的一项杰出成就。

此外,USACO还会提供许多学习资源来协助参赛者提高他们的编程技能。官方网站提供了包括比赛历史、比赛规则、解题方法和教程等在内的许多资源,以帮助选手们更好地理解学术活动问题并更有效地解决问题。此外,USACO还开设了在线课程,通过这些课程,学生可以掌握更多的编程技能,并从资深的程序员那里获得更多的指导。

请扫码可免费获取学术活动真题及资料

总之,USACO是一场激励、鼓励和挑战的编程学术活动,不仅可帮助参赛者发展其编程技能,还能够促进他们在计算机领域的学术和职业发展。

usaco竞赛考试形式是什么样?USACO计算机竞赛的考试计时形式

usaco学术活动考试形式是什么样?USACO学术活动分为四个级别,即铜(Bronze)、银(Silver)、金(Gold)和铂金(Platinum)级别。所有参赛者初始均为铜级别。每个比赛周结束后,如果参赛者获得足够高的分数,就会被晋升到下一个级别。通常,需要获得600-800分(满分1000分)才能晋升。

此外,在比赛周末中获得所有问题的满分也可以直接获得晋升。每一个级别都比前一个级别难度更高,通常需要相当多的学习和训练才能提升到新的水平。每个级别长达一年或更长时间。2015年,USACO增加了铂金级别。在此之前,每个级别的难度都比现在大,大约相当于现在的级别“向上一步”。例如,旧版的青铜级别问题最接近现在的银级别难度。

比如Bronze级别,学术活动题目可以分为三种类型。

第一种类型是simulation,考生只需要使用algorithm和coding实现一个process就可以完成。这类题目相对比较简单,适合那些初学者,可以帮助他们熟悉编程语言和基本算法。

第二种类型是greedy algorithm,这类题目比较tricky,需要孩子有更多的observation和analysis方面的训练。参赛者需要掌握贪心算法等相关算法来解决问题。

第三种类型是search,也就是我们常说的暴力法,需要能够用一种枚举思路来考虑问题。参赛者需要了解搜索算法并能够应用到具体问题中去。

掌握了这三种基本题型的解题方法,从知识角度上看就没有太大的问题。剩下的主要在编程能力方面,是否能够将这三种题目的algorithm转化为coding,并且能够正确地通过test case。因此,可以说Bronze级别主要考察参赛者的编程实现能力和基础算法能力。

请扫码可免费获取学术活动真题及资料

对于不同级别的学术活动,它们的难度等级也不同。

青铜级别适合那些刚学会编程的学生,需要掌握基本的排序和二进制搜索等基本概念,没有算法方面的培训。

白银级别需要具备基本的问题解决能力和简单算法(如贪心算法、递归搜索),并且需要了解基础数据结构。从银级别开始,选手需要寻找更好的算法才能使程序在规定时间内顺利运行。

黄金级别需要有一定的算法基础,理解一些抽象的方法,如最短路径、动态规划,并且对数据结构有较深的了解。

铂金级别需要有很高的编程基础和深入的算法知识,部分比赛问题可能有多个最优解决方案,得出的答案也可能不止一个。

在USACO学术活动中,考试的计时形式是,在比赛周的任何时间进入网站并点击按钮启动个人比赛计时器,时间通常为3-5个小时,具体限制时间会在赛前告知,通常为4小时。一旦开始计时,无法暂停,在时间结束前可以休息或提前停止。如果只是想检查题目,可以随意花费时间。如果目标是全面完成,需要提前计划整个时间段,以避免分心。

USACO学术活动不仅为学生提供了一个锻炼自己能力的机会,同时也提供了许多奖学金、荣誉和就业机会。参赛者不仅可以通过此学术活动提升自己的编程能力,还能够与其他志同道合的人建立联系,并加入USACO社区,共同学习和探索计算机科学和信息技术的新领域。

usaco竞赛的诚信要求有哪些,USACO竞赛规则介绍

usaco学术活动的诚信要求有哪些?为确保USACO学术活动的诚信,该学术活动采取了严格的政策和明确的规定:

1.必须独立完成比赛,禁止在团队环境中工作。

2.禁止在比赛负责人以外的人协商比赛问题。

3.不得提交与他人合作编写的程序。

4.鼓励参赛者不要使用书本或网站上的代码。在开发过程中,不得在网上搜索确切的解决方案,或使用在USACO或类似网站上发布的解决方案。如果必须从书本或网站上查找一些代码(或更普遍的,任何你没有从头开始写的东西),请在代码中插入一个注释,告知来源。

允许学生为一些小的代码查阅一般的参考资料,如如何调用标准库函数、读取输入、格式化输出等。但是,学生不应该复制其他人编写的大段代码,比如整个算法。

5.禁止使用两个登录ID参加一个以上的部门。禁止使用另一个登录ID来阅读问题,以规避比赛的时间限制。

6.禁止提交任何对评分机有恶意行为的代码,比如试图打开网络连接、故意降低评分机的速度等。评判环境会对活动和系统调用进行监控,以防止被禁止的行为。

7.在比赛仍在进行时,不得分享参赛代码。

8.违反上述任何政策的参赛者将被终身禁止参加所有USACO活动。作弊者将取消将来参赛资格。

参加USACO学术活动的益处是什么?

USACO学术活动注重考察学生在解决问题和算法实际应用方面的能力。参赛者需要综合运用所有相关知识,通过编程控制计算机来解题。这一过程可以有效提高学生的解决问题能力。

参加USACO学术活动,同学们需要独立思考并整合相关知识点,例如数理逻辑、数据结构、算法、计算机体系结构、英语理解等。他们需要利用各种能力包括计算思维、数据收集以及刻意练习,设计并实现编程项目,验证其正确性并反复修改。这是同学们在校内学习难以培养的能力。

请扫码可免费获取学术活动真题及资料

USACO学术活动是一个极具权威性的学术活动,它能够帮助参赛者以最小的成本提升自己的学术背景。特别是那些计划申请或正在准备申请知名大学计算机专业的同学,如果参加USACO并获得金奖以上,将会大大增强他们在升学竞争中的竞争力。