2024年2月美国计算机奥赛USACO竞赛金奖组问题二——Milk Exchange

Farmer John's N(1≤N≤5⋅105)cows are lined up in a circle. The ith cow has a bucket with integer capacity ai (1≤ai≤109) liters. All buckets are initially full.

Every minute, cow i will pass all the milk in their bucket to cow i+1 for 1≤i<N, with cow N passing its milk to cow 1. All exchanges happen simultaneously (i.e., if a cow has a full bucket but gives away x liters of milk and also receives x
liters, her milk is preserved). If a cow's total milk ever ends up exceeding ai, then the excess milk will be lost.

After each of 1,2,…,N minutes, how much total milk is left among all cows?

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

The first line contains N.

The next line contains integers a1,a2,…,aN

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

Output N lines, where the i-th line is the total milk left among all cows after i
minutes.

SAMPLE INPUT:

6
2 2 2 1 2 1

SAMPLE OUTPUT:

8
7
6
6
6
6

Initially, the amount of milk in each bucket is [2,2,2,1,2,1].

After 1 minute, the amount of milk in each bucket is [1,2,2,1,1,1] so the total amount of milk is 8.

After 2 minutes, the amount of milk in each bucket is [1,1,2,1,1,1] so the total amount of milk is 7.

After 3 minutes, the amount of milk in each bucket is [1,1,1,1,1,1] so the total amount of milk is 6.

After 4 minutes, the amount of milk in each bucket is [1,1,1,1,1,1] so the total amount of milk is 6.

After 5 minutes, the amount of milk in each bucket is [1,1,1,1,1,1] so the total amount of milk is 6.

After 6 minutes, the amount of milk in each bucket is [1,1,1,1,1,1] so the total amount of milk is 6.

SAMPLE INPUT:

8
3 8 6 4 8 3 8 1

SAMPLE OUTPUT:

25
20
17
14
12
10
8
8

After 1 minute, the amount of milk in each bucket is [1,3,6,4,4,3,3,1] so the total amount of milk is 25.

SAMPLE INPUT:

10
9 9 10 10 6 8 2 1000000000 1000000000 1000000000

SAMPLE OUTPUT:

2000000053
1000000054
56
49
42
35
28
24
20
20

SCORING:

Inputs 4-5: N≤2000
Inputs 6-8: ai ≤2
Inputs 9-13: All ai are generated uniformly at random in the range [1,109].
Inputs 14-23: No additional constraints.

Problem credits: Chongtian Ma, Alex Liang, Patrick Deng

扫码领取USACO试题答案+详细解析

咨询一对一备赛规划

2024年2月美国计算机奥赛USACO竞赛金奖组问题一——Bessla Motors

**Note: The time limit for this problem is 3s, 1.5x the default. The memory limit for this problem is 512MB, twice the default.**

Farmer John would like to promote his line of Bessla electric tractors by showcasing Bessla's network of charging stations. He has identified N
(2≤N≤5⋅104) points of interest labeled 1…N, of which the first C
(1≤C<N) are charging stations and the remainder are travel destinations. These points of interest are interconnected by M (1≤M≤105) bidirectional roads, the i-th of which connects distinct points ui and vi (1≤ui,viN) and has length i miles (1≤i ≤109).

A Bessla can travel up to 2R miles (1≤R≤109) on a single charge, allowing it to reach any destination within R miles of a charging station. A destination is deemed well-connected if it is reachable from at least K(1≤K≤10) distinct charging stations. Your task is to assist Farmer John in identifying the set of well-connected travel destinations.

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

The first line contains five space-separated integers N, M, C, R, and K. Each of the following M lines contains three space-separated integers ui, vi, and i such that uivi.

The charging stations are labeled 1,2,…,C. The remaining points of interest are all travel destinations.

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

First, output the number of well-connected travel destinations on a single line. Then, list all well-connected travel destinations in ascending order, each on a separate line.

SAMPLE INPUT:

3 3 1 4 1
1 2 3
1 3 5
2 3 2

SAMPLE OUTPUT:

1
2

We have one charging station at 1. From this charging station, we can reach point 2(since it is distance 3 away from 1), but not point 3 (since it is distance 5 away from 1). Thus, only point 2 is well-connected.

SAMPLE INPUT:

4 3 2 101 2
1 2 1
2 3 100
1 4 10

SAMPLE OUTPUT:

2
3
4

We have charging stations at 1 and 2, and both points 3 and 4 are within distance 101 of both 1 and 2. Thus, both points 3 and 4 are well-connected.

SAMPLE INPUT:

4 3 2 100 2
1 2 1
2 3 100
1 4 10

SAMPLE OUTPUT:

1
4

SCORING:

Inputs 4 and 5: K=2 and N≤500 and M≤1000.
Inputs 6 and 7: K=2.
Inputs 8-15: No additional constraints.

Problem credits: Alexander Wei

扫码领取USACO试题答案+详细解析

咨询一对一备赛规划

2024年2月美国计算机奥赛USACO竞赛白金组问题三——Infinite Adventure

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

Bessie is planning an infinite adventure in a land with N (1≤N≤105) cities. In each city i, there is a portal, as well as a cycling time Ti. All Ti's are powers of 2, and T1+⋯+TN≤105. If you enter city i's portal on day t, then you instantly exit the portal in Ci,t  mod Ti.

Bessie has Q(1≤Q≤5⋅104) plans for her trip, each of which consists of a tuple (v,t,Δ). In each plan, she will start in city v on day t. She will then do the following Δ times: She will follow the portal in her current city, then wait one day. For each of her plans, she wants to know what city she will end up in.

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

The first line contains two space-separated integers: N, the number of nodes, and Q, the number of queries.

The second line contains N space-separated integers: T1, T2,…,TN
(1≤Ti, Ti is a power of 2, and T1+⋯+TN≤105).

For i=1,2,…,N, line i+2 contains Ti space-separated positive integers, namely Ci,0,…,ci,Ti−1(1≤Ci,tN).

For j=1,2,…,Q, line j+N+2 contains three space-separated positive integers,vj,tj,Δj(1≤vjN, 1≤tj≤1018, and 1≤Δj≤1018) representing the j
th query.

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

Print Q lines. The jth line must contain the answer to the jth query.

SAMPLE INPUT:

5 4
1 2 1 2 8
2
3 4
4
2 3
5 5 5 5 5 1 5 5
2 4 3
3 3 6
5 3 2
5 3 7

SAMPLE OUTPUT:

2
2
5
4

Bessie's first three adventures proceed as follows:

In the first adventure, she goes from city 2 at time 4 to city 3 at time 5, to city 4 at time 6, to city 2 at time 7.
In the second adventure, she goes from city 3 at time 3 to city 4 at time 4, to city 2 at time 5, to city 4 at time 6, to city 2 at time 7, to city 4 at time 8, to city 2 at time 9.

In the third adventure, she goes from city 5 at time 3 to city 5 at time 4, to city 5 at time 5.

SAMPLE INPUT:

5 5
1 2 1 2 8
2
3 4
4
2 3
5 5 5 5 5 1 5 5
2 4 3
3 2 6
5 3 2
5 3 7
5 3 1000000000000000000

SAMPLE OUTPUT:

2
3
5
4
2

SCORING:

Input 3:Δj≤2⋅102.
Inputs 4-5: N,∑Tj≤2⋅103.
Inputs 6-8: N,∑Tj≤104.
Inputs 9-18: No additional constraints.

Problem credits: Brandon Wang

扫码领取USACO试题答案+详细解析

咨询一对一备赛规划

2024年2月美国计算机奥赛USACO竞赛白金组问题二——Minimum Sum of Maximums

Bessie has N (2≤N≤300) tiles in a line with ugliness values a1,a2,…,aN in that order (1≤ai≤106). K(0≤K≤min(N,6)) of the tiles are stuck in place; specifically, those at indices x1,…,xK(1≤x1<x2<⋯<xKN).

Bessie wants to minimize the total ugliness of the tiles, which is defined as the sum of the maximum ugliness over every consecutive pair of tiles; that is, She is allowed to perform the following operation any number of times: choose two tiles, neither of which are stuck in place, and swap them.

Determine the minimum possible total ugliness Bessie can achieve if she performs operations optimally.

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

The first line contains N and K.

The next line contains a1,…,aN .

The next line contains the K indices x1,…,xK.

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

Output the minimum possible total ugliness.

SAMPLE INPUT:

3 0
1 100 10

SAMPLE OUTPUT:

110

Bessie can swap the second and third tiles so that a=[1,10,100], achieving total ugliness max(1,10)+max(10,100)=110. Alternatively, she could swap the first and second tiles so that a=[100,1,10], also achieving total ugliness max(100,1)+max(1,10)=110.

SAMPLE INPUT:

3 1
1 100 10
3

SAMPLE OUTPUT:

110

Bessie could swap the first and second tiles so that a=[100,1,10]
, achieving total ugliness max(100,1)+max(1,10)=110.

SAMPLE INPUT:

3 1
1 100 10
2

SAMPLE OUTPUT:

200

The initial total ugliness of the tiles is max(1,100)+max(100,10)=200
. Bessie is only allowed to swap the first and third tiles, which does not allow her to reduce the total ugliness.

SAMPLE INPUT:

4 2
1 3 2 4
2 3

SAMPLE OUTPUT:
9

SCORING:

Input 5: K=0
Inputs 6-7: K=1
Inputs 8-12: N≤50
Inputs 13-24: No additional constraints
Problem credits: Benjamin Qi

扫码领取USACO试题答案+详细解析

咨询一对一备赛规划

2024年2月美国计算机奥赛USACO竞赛白金组问题一——Lazy Cow

Bessie is hard at work preparing test cases for the USA Cowmputing Olympiad February contest. Each minute, she can choose to not prepare any tests, expending no energy; or expend 3a−1 energy preparing a test cases, for some positive integer a.

Farmer John has D (1≤D≤2⋅105) demands. For the ith demand, he tells Bessie that within the first mi minutes, she needs to have prepared at least bi test cases in total (1≤mi≤106,1≤bi≤1012).

Let ei be the smallest amount of energy Bessie needs to spend to satisfy the first i
demands. Print e1,…,eD modulo 109+7.

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

The first line contains D. The ith of the next D lines contains two space-separated integers mi and bi .

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

Output D lines, the ith containing ei mod 109+7.

SAMPLE INPUT:

4
5 11
6 10
10 15
10 30

SAMPLE OUTPUT:

21
21
25
90

For the first test case,

i=1: If Bessie creates [2,3,2,2,2] test cases on the first 5 days, respectively, she would have expended 31+32+31+31+31=21 units of energy and created 11
test cases by the end of day 5.

i=2: Bessie can follow the above strategy to ensure 11 test cases are created by the end of day 5, and this will automatically satisfy the second demand.

i=3: If Bessie creates [2,3,2,2,2,0,1,1,1,1] test cases on the first 10 days, respectively, she would have expended 25 units of energy and satisfied all demands. It can be shown that she cannot expend less energy.

i=4: If Bessie creates 3 test cases on each of the first 10 days she would have expended 32⋅10=90 units of energy and satisfied all demands.
For each i, it can be shown that Bessie cannot satisfy the first i demands using less energy.

SAMPLE INPUT:

2
100 5
100 1000000000000
SAMPLE OUTPUT:
5
627323485

SAMPLE INPUT:

20
303590 482848034083
180190 112716918480
312298 258438719980
671877 605558355401
662137 440411075067
257593 261569032231
766172 268433874550
8114 905639446594
209577 11155741818
227183 874665904430
896141 55422874585
728247 456681845046
193800 632739601224
443005 623200306681
330325 955479269245
377303 177279745225
880246 22559233849
58084 155169139314
813702 758370488574
929760 785245728062

SAMPLE OUTPUT:

108753959
108753959
108753959
148189797
148189797
148189797
148189797
32884410
32884410
32884410
32884410
32884410
32884410
32884410
3883759
3883759
3883759
3883759
3883759
3883759

SCORING:

Inputs 4-5: D≤100 and mi≤100 for all i
Inputs 6-8: D≤3000
Inputs 9-20: No additional constraints.

Problem credits: Brandon Wang and Claire Zhang

扫码领取USACO试题答案+详细解析

咨询一对一备赛规划

USACO晋级情况如何?USACO竞赛2023-2024赛季分数线汇总!

CS专业在留学圈中一直被视为兼具热度与难度、前景与钱景的专业。许多中学生志在CS专业,他们会通过参加各种相关活动及比赛来为自己的Profile增加专业光环。其中,USACO(国计算机奥林匹克竞赛)是一个参与度较高的比赛。

USACO晋级情况

满分晋级

如果选手在赛时拿到满分。可以在同一场比赛的时间段内再次参与高一个级别的比赛。也就是说,理论上可以在一场比赛的四天里面从青铜打到白金。

常规晋级

比赛结束后组织者根据全部选手的成绩划定分数线,分数线上的选手在下一场比赛的时候晋级到更高级别。

晋级分数线的划定不是固定的,是从这场比赛参赛选手的成绩根据比例反推的分数线。一般来说,在一场比赛的三道题当中,要拿到两道半才能晋级。

晋级率

USACO竞赛参赛人数越来越多,USACO竞赛在近几年的发展过程中:Bronze铜级别的通过率大概在15%左右,Silver银级别的通过率则是在5-6%之间,而Gold金级别的通过率则仅为2-3%。

USACO竞赛分数线

2023-2024赛季分数线:

2023-2024赛季 12月赛事

(Bronze铜级)分数线:青铜级别总参赛人数为12591,晋级分数线为700分+

(Silver银级)分数线:总参赛人数为3841,晋级分数线为750分+

(Gold金级)分数线:总参赛人数为1375,晋级分数线为800分+

(铂金级)分数线:铂金级别共有673名参赛学生

1月USACO比赛晋级分数线

Bronze铜级分数线:

总参赛人数为8454,晋级分数线为750分+。

Silver银级分数线:

总参赛人数为3920,晋级分数线为750分+。

Gold金级分数线:

总参赛人数为940,晋级分数线为800分+。

Platinum铂金级分数线:

铂金级别共有489名参赛学生。

扫码免费领取USACO计算机竞赛备考资料

金牌导师&精编讲义“强强联手”

扫码咨询USACO长线备考班、冲刺班课程详情,了解课程优惠!

USACO竞赛编程语言应该怎么选?USACO竞赛各级别能力有何要求?

近年来,随着国内信奥学习热度的不断增长,参加USACO计算机竞赛的国内选手人数也与日俱增。2024年度新赛季的USACO竞赛已经开启。虽然USACO是一个国的竞赛,但对于其他国家的同学来说也是非常友好的。

USACO竞赛各级别的能力要求:

铜级:

- 要求掌握基本编程知识,至少熟练掌握一种编程语言。

- 铜级问题通常没有太多的效率问题,重点在于理解题意,设计算法解决问题。

银级:

- 在铜级的基础上,引入了数据结构包括堆、栈、列表、树以及相对应的排序、搜索算法,并广泛应用。

- 算法的效率和复杂度成为重点,一般的简单方法如穷举法将不再适用。

金级:

- 在银级的基础上,要求掌握基本的数据结构如列表、堆、栈、集合、关联数组和相关的算法,并广泛应用。

- 需要应用更复杂的数据结构,包括树和图的算法,以及动态规划、数论和排列组合等。

铂金级:

- 要求对算法有深入了解,能够解决复杂问题和开放问题。

- 题目复合多种算法,还会涉及高难度辅助算法,思维难度大,编码工作量也在加大。

USACO竞赛编程语言应该怎么选?

根据年级选择

- 7年级之前,学生可以学习Python语言,因为它更容易入门。

- 7年级之后,学生们可以学习更多的语言,因为语言之间是相通的,如果掌握了一门语言的基础,学习其他语言会更容易。

- 到了10年级,建议学生掌握C++语言,特别是对于冲刺USACO更高阶的级别,或者冲刺NOI竞赛都非常有用。

根据竞赛级别/难度选择

- C++语言运行速度最快,在白金以上级别中使用较多,在集训队和国际竞赛级别应用广泛。

- Java是美国高中AP考试的编程语言,有不少考生考到白金和集训队。

- Python是新兴语言,适用于人工智能AI和大数据Data science,有更广阔的就业机会和前景。目前已经有不少考生用Python考到了金级。

根据个人兴趣、目标和竞赛级别来选择编程语言,这样可以更好地发挥自己的优势,提高在USACO竞赛中的竞争力。

扫码免费领取USACO计算机竞赛备考资料

金牌导师&精编讲义“强强联手”

扫码咨询USACO长线备考班、冲刺班课程详情,了解课程优惠!

USACO竞赛备考学到什么程度可以参赛?USACO竞赛夺金必看的备考技巧!

对于那些对CS专业充满热情并渴望在申请过程中脱颖而出的中学生来说,参加USACO计算竞赛是一个非常值得考虑的选择。它不仅可以为他们的申请增添亮点,还有可能为他们打开通往世界一流大学的门。无论身处何地,只要你有CS的热情和决心,USACO竞赛都将是一个让你展示自己才华的舞台。

竞赛考察内容

铜级

铜级考察的是编程基础知识的掌握程度,主要包括:解释编程问题、创建基本算法和逻辑、将想法转化为代码。

银级

银级考试相对铜级更难,涉及:递归搜索、贪心算法等基本问题求解技术、基础数据结构概念、考察效率问题。

黄金

考察更复杂的标准算法,如最短路径、动态规划等、要求熟练掌握数据结构,主要考察效率问题。

铂金

要求对算法有深入了解,熟练应用,能解决复杂问题和开放问题。

USACO竞赛备考学到什么程度可以参赛?

新注册的选手默认从铜组开始,基本上能参加 CSP-J/S 入门级的同学就可以参加,难度具体可以参考以下图:

备考技巧

攻克英语:

英语是编程学习的基础,参加USACO竞赛需要熟练掌握英语,因为编程是使用英语体系语言的。因此,学生需要注重英语的学习,这将成为学习算法语言和参加USACO竞赛的基础。

以小见大的思维能力:

学生需要培养将大问题分解为小问题并逐一解决的思维能力。这种分而治之的思考方法是一种相当工程化的思维,也是科学技术在过去的两百年里的统治性思维。这种思维方式有助于解决复杂的编程问题。

选择正确的学习语言:

初学者选择合适的编程语言非常重要,因为它会影响学习效果和成就感的达成。参赛者需要选择一种编程语言并深入学习,以便为USACO竞赛做好准备。

扫码免费领取USACO计算机竞赛备考资料

金牌导师&精编讲义“强强联手”

扫码咨询USACO长线备考班、冲刺班课程详情,了解课程优惠!

USACO信息学奥赛有没有监考?附USACO竞赛常见问题!

竞赛在美国大学申请中变得越来越重要。在越来越卷的活动列表中,竞赛已经成为每个想要冲刺顶尖名校的学生必不可少的参与项目。参加USACO计算机竞赛不仅能够锻炼学生的编程能力,还能提升他们在申请过程中的竞争力。

参赛流程

USACO为个人赛,学生可在官网自主报名参赛。在每次月赛指定的日期范围内的任何一个时间打开USACO题目完成考试即可,比赛需在规定时间内完成3-4道题目,每次考试满分1000分。

USACO竞赛采取积分赛制,总共分为四个梯队,由低到高分别是:铜级、银级、黄金、白金。比赛分为月赛和公开赛两轮,所有参与者都要经过一轮轮的晋级,每一轮比赛中,选手都有机会获得下一轮比赛的晋级资格。

USACO竞赛常见问题  

1.有一定编程经验, USACO建议从什么等级打起?

所有人注册的时候都是从铜级Bronze打起,当前等级拿高分后才能晋级。如果要评估自己水平,可以找小助手领取往年试题,来评估自己水平。

2.USACO 能否多次提交答案?

可以多次提交答案,覆盖之前的答案提交,直到正确为止。

但建议先思考出正确思路再提交。

3.晋级白金后还有什么比赛?

晋级白金后,12月,1月,2月,3月都可以参加白金 Platinum 比赛,刷分冲刺排行榜。

4.USACO 没有监考吗?

USACO 是没有监考的。它针对美国高中生的信息学选拔赛,也就是说,如果你是美国国籍的高中生,通过参加 USACO 选拔,是很有可能参加线下夏令营 Training camp 选拔,代表美国去参加世界信息学竞赛( IOI )的。但如果你没有那个水平,而是请人代考获得资格的,你敢去参加线下的夏令营选拔吗?所以对组委会来说,他们没必要设置监考。不过对于高分段选手的代码,电脑进行查重是很容易的,所以学生如果没有对应能力,从网上随便找人帮忙弄了一份代码,直接提交,那很容易出现问题,被封号禁赛。

扫码免费领取USACO计算机竞赛备考资料

金牌导师&精编讲义“强强联手”

扫码咨询USACO长线备考班、冲刺班课程详情,了解课程优惠!

为什么推荐USACO竞赛?USACO可以使用哪些编程语言?

USACO竞赛的晋级过程对大学申请有很大的帮助。除了申请大学以外,USACO对于美高(美国顶尖高中)的申请也有很大的助力。每年都有许多学生通过USACO竞赛成功申请到排名前十的名校。由于USACO竞赛的极高含金量,全球范围内的参与度也在逐年暴增。

USACO使用的编程语言

USACO接受多种语言的解决方案,包括C++,C,Java,Python。由于Java和Python相比于C++/C语言运行的会慢一些,所以这两种语言所允许的运行时间是C++和C的两倍。相比于国内NOIP只接受C++作为考试语言,USACO提供了更加灵活的支持,使得比较喜欢Java和Python的人也有机会参与到算法竞赛中。

为什么推荐USACO竞赛?

全球影响力和认可度高:

USACO竞赛吸引了来自世界各地的优秀学子参与,许多获奖者都获得了美国顶尖大学的青睐,成为学术和工业界的明日之星。参与USACO竞赛,将为学生的学术和职业发展奠定坚实基础。

提升综合能力:

USACO竞赛的题目涵盖了编程技巧、算法设计、数据结构、人工智能等多个领域,要求参赛者在多个维度上展现自己的实力,从而提高学生的综合能力。

考验实战应用能力:

竞赛题目往往来源于现实生活中的问题,要求学生运用所学知识解决实际问题。这种实战应用的导向,使得参赛者在未来的学习和职业生涯中更具竞争力。

学术荣誉:

USACO竞赛的获奖者将获得极高的学术荣誉,为他们的学术和职业发展铺平道路。许多获奖者都获得了世界顶级大学的录取通知和丰厚的奖学金,为他们的未来发展提供了有力支持。

USACO竞赛考核的重点在于学生的两方面能力:

1.算法分析能力

2.代码编写能力

算法分析能力,即对通过对题目的正确分析及理解,找到解题思路;

代码编写能力,即把解题思路、算法逻辑转换成代码。

扫码免费领取USACO计算机竞赛备考资料

金牌导师&精编讲义“强强联手”

扫码咨询USACO长线备考班、冲刺班课程详情,了解课程优惠!