USACO2024年公开赛美国计算机奥赛竞赛金奖组问题三——Smaller Averages

Bessie has two arrays of length N(1≤N≤500). The i-th element of the first array is ai (1≤ai≤106) and the i-th element of the second array is bi (1≤bi≤106).

Bessie wants to split both arrays into non-empty subarrays such that the following is true.

1.Every element belongs in exactly 1 subarray.
2.Both arrays are split into the same number of subarrays. Let the number of subarrays the first and second array are split into be k (i.e. the first array is split into exactly k subarrays and the second array is split into exactly k subarrays).
3.For all 1≤ik, the average of the i-th subarray on the left of the first array is less than or equal to the average of the i-th subarray on the left of the second array.

Count how many ways she can split both arrays into non-empty subarrays while satisfying the constraints modulo 109+7. Two ways are considered different if the number of subarrays are different or if some element belongs in a different subarray.

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

The first line contains N.

The next line contains al,a2,...,aN.

The next line contains b1,b2,...,bN.

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

Output the number of ways she can split both arrays into non-empty subarrays while satisfying the constraints modulo 109+7.

SAMPLE INPUT:

2
1 2
2 2

SAMPLE OUTPUT:

2

The two valid ways are:

1.Split the first array into [1],[2] and the second array into [2],[2].
2.Split the first array into [1,2] and the second array into [2,2].

SAMPLE INPUT:

3
1 3 2
2 2 2

SAMPLE OUTPUT:

3

The three valid ways are:

1.Split the first array into [1,3],[2] and the second array into [2,2],[2].
2.Split the first array into [1,3],[2] and the second array into [2],[2,2].
3.Split the first array into [1,3,2] and the second array into [2,2,2].

SAMPLE INPUT:

5
2 5 1 3 2
2 1 5 2 2

SAMPLE OUTPUT:

1

The only valid way is to split the first array into [2],[5,1,3],[2] and the second array into [2],[1,5],[2,2].

SAMPLE INPUT:

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

SAMPLE OUTPUT:

140

SCORING:

Inputs 5-6: N≤10
Inputs 7-9: N≤80
Inputs 10-17: N≤300
Inputs 18-20: N≤500

Problem credits: Alex Liang

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

咨询一对一备赛规划

USACO竞赛考试网-二维码

USACO2024年公开赛美国计算机奥赛竞赛金奖组问题二——Grass Segments

Bessie is planting some grass on the positive real line. She has N (2≤N≤2⋅105) different cultivars of grass, and will plant the ith cultivar on the interval [i,ri](0<i<ri≤109).

In addition, cultivar i grows better when there is some cultivar j (ji) such that cultivar j and cultivar i overlap with length at least ki (0<kirii). Bessie wants to evaluate all of her cultivars. For each i, compute the number of ji such that j and ioverlap with length at least ki.

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

The first line contains N.
The next N lines each contain three space-separated integers i, ri, and ki.

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

The answers for all cultivars on separate lines.

SAMPLE INPUT:

2
3 6 3
4 7 2

SAMPLE OUTPUT:
0
1

The overlaps of the cultivars is [4,6], which has length 2, which is at least 2 but not at least 3.

SAMPLE INPUT:

4
3 6 1
2 5 1
4 10 1
1 4 1

SAMPLE OUTPUT:

3
3
2
2

SAMPLE INPUT:

5
8 10 2
4 9 2
3 7 4
5 7 1
2 7 1

SAMPLE OUTPUT:

0
3
1
3
3

SCORING:

Input 4-5: N≤5000
Inputs 6-11: k is the same for all intervals
Inputs 12-20: No additional constraints.
In addition, for Inputs 5, 7, ..., 19, ri≤2N for all i.

Problem credits: Benjamin Qi

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

咨询一对一备赛规划

USACO竞赛考试网-二维码

USACO2024年公开赛美国计算机奥赛竞赛金奖组问题一——Cowreography

The cows have formed a dance team, and Farmer John is their choreographer! The team's latest and greatest dance involves N cows (2≤N≤106 ) standing in a line. Each move in the dance involves two cows, up to K positions apart (1≤K<N
), gracefully jumping and landing in each other's position.

There are two types of cows in the line – Guernseys and Holsteins. As such, Farmer John has documented the dance as a sequence of length-N
binary strings, where a 0 represents a Guernsey, a 1 represents a Holstein, and the overall string represents how the cows are arranged in the line.

Unfortunately, Farmer Nhoj (who choreographs for a rival team) has sabotaged the dance and erased all but the first and last binary strings! With a big competition quickly approaching, Farmer John must waste no time in reconstructing the dance.

Given these two binary strings, help Farmer John find the minimum number of moves in the dance!

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

The first line contains N and K.

The second line contains the first binary string.

The third line contains the last binary string.

It is guaranteed that both binary strings contain the same number of ones.

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

The minimum number of moves in the dance.

SAMPLE INPUT:

4 1
0111
1110

SAMPLE OUTPUT:

3

One possible dance:

0111 -> 1011 -> 1101 -> 1110

SAMPLE INPUT:

5 2
11000
00011

SAMPLE OUTPUT:

3

One possible dance:

11000 -> 01100 -> 00110 -> 00011

SAMPLE INPUT:

5 4
11000
00011

SAMPLE OUTPUT:

2

One possible dance:

11000 -> 10010 -> 00011

SCORING:

Inputs 4-5: K=1
Inputs 6-7: Both strings have at most 8
ones.
Inputs 8-15: N≤5000
Inputs 16-23: No additional constraints.

Problem credits: Benjamin Qi

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

咨询一对一备赛规划

USACO竞赛考试网-二维码

USACO2024年公开赛美国计算机奥赛竞赛白金奖组问题三——Activating Robots

You and a single robot are initially at point 0 on a circle with perimeter L
(1≤L≤109). You can move either counterclockwise or clockwise along the circle at 1 unit per second. All movement in this problem is continuous.

Your goal is to place exactly R−1 robots such that at the end, every two consecutive robots are spaced L/R away from each other (2≤R≤20, R
divides L). There are N (1≤N≤105) activation points, the ith of which is located ai distance counterclockwise from 0(0≤ai<L). If you are currently at an activation point, you can instantaneously place a robot at that point. All robots (including the original) move counterclockwise at a rate of 1 unit per K seconds (1≤K≤106).

Compute the minimum time required to achieve the goal.

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

The first line contains L, R, N, and K.
The next line contains N
space-separated integersa1,a2,…,aN.

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

The minimum time required to achieve the goal.

SAMPLE INPUT:

10 2 1 2
6

SAMPLE OUTPUT:

22

We can reach the activation point at 6 in 4 seconds by going clockwise. At this time, the initial robot will be located at 2. Wait an additional 18 seconds until the initial robot is located at 1. Now we can place a robot to immediately win.

SAMPLE INPUT:

10 2 1 2
7

SAMPLE OUTPUT:

4

We can reach the activation point at 7 in 3 seconds by going clockwise. At this time, the initial robot will be located at 1.5. Wait an additional second until the initial robot is located at 2. Now we can place a robot to immediately win.

SAMPLE INPUT:

32 4 5 2
0 23 12 5 11

SAMPLE OUTPUT:

48

SAMPLE INPUT:

24 3 1 2
16

SAMPLE OUTPUT:

48

SCORING:

Inputs 5-6: R=2
Inputs 7-12: R≤10,N≤80
Inputs 13-20: R≤16
Inputs 21-24: No additional constraints.

Problem credits: Benjamin Qi

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

咨询一对一备赛规划

USACO竞赛考试网-二维码

USACO2024年公开赛美国计算机奥赛竞赛白金奖组问题二——Splitting Haybales

Farmer John wants to fairly split haybales between his two favorite cows Bessie and Elsie. He has N( 1≤N≤2⋅105) haybales sorted in non-increasing order, where the i-th haybale has aiunits of hay (2⋅105a1a2≥⋯≥aN≥1).

Farmer John is considering splitting a contiguous range of haybales al,…,ar between Bessie and Elsie. He has decided to process the haybales in order from l
to r, and when processing the i-th haybale he will give it to the cow who currently has less hay (if it is a tie, he will give it to Bessie).

You are given Q(1≤Q≤2⋅105) queries, each with three integers l,r,x(1≤lrN
, |x|≤109). For each query, output how many more units of hay Bessie will have than Elsie after processing haybales l to r, if Bessie starts with x more units than Elsie. Note that this value is negative if Elsie ends up with more haybales than Bessie.

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

First line contains N.

Second line contains a1aN.

Third line contains Q.

Next Q lines contain l,r,x.

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

Output Q lines, containing the answer for each query.

SAMPLE INPUT:

2
3 1
15
1 1 -2
1 1 -1
1 1 0
1 1 1
1 1 2
1 2 -2
1 2 -1
1 2 0
1 2 1
1 2 2
2 2 -2
2 2 -1
2 2 0
2 2 1
2 2 2

SAMPLE OUTPUT:

1
2
3
-2
-1
0
1
2
-1
0
-1
0
1
0
1

For the 1st query, Elsie starts with 2 more hay than Bessie. Then, after processing haybale 1, Bessie will receive 3 hay, and Bessie will have 1 more hay than Elsie.

For the 3rd query, Elsie and Bessie start with the same number of hay. After processing haybale 1, Bessie will receive 3 hay, and Bessie will have 3
more hay than Elsie.

For the 9th query, Bessie starts with 1 more hay than Elsie, then after processing the 1st haybale, has 2 less hay than Elsie, and after processing the 2nd haybale, has 1 less hay than Elsie.

SAMPLE INPUT:

5
4 4 3 1 1
7
1 1 20
1 2 20
1 5 20
1 1 0
1 5 0
1 4 0
3 5 2

SAMPLE OUTPUT:

16
12
7
4
1
2
1

In the 5th query, there are 5 haybales to process. Bessie receives 4 hay, then Elsie receives 4 hay, then Bessie receives 3 hay, then Elsie receives 1 hay, then Elsie receives 1 hay.

SCORING:

Input 3: Q≤100
Inputs 4-6: At most 100
distinct ai
Inputs 7-22: No additional constraints.

Problem credits: Benjamin Qi

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

咨询一对一备赛规划

USACO2024年公开赛美国计算机奥赛竞赛白金奖组问题一——Identity Theft

**Note: The time limit and memory limit for this problem are 3s and 512MB, which are 1.5x and 2x the normal amount, respectively.**

Farmer John's N (1≤N≤105) cows each have a Farm ID number in the form of a bitstring (a string consisting of the characters '0' and '1'). Bessie, the eldest cow, has the Farm ID numbers of all the cows memorized, and likes to go around and ask cows their ID numbers.

When a cow is asked their Farm ID number, they will start to say the correct bitstring, but may get confused and stop before finishing it. When Bessie hears the bitstring, if it is not the Farm ID number of any cow on the farm, then she will shrug and walk off. However, if it is the ID number of a different cow than the one she asked, then she will assume that identity theft has occurred and place the farm into lockdown. Note that this can happen even when the cow says their full Farm ID number.

Farmer John would like to prevent this from happening, and is willing to change the cows' Farm ID numbers by adding some more bits to them. In one second, he can add one bit to the end of the Farm ID number of any cow. Figure out the minimum amount of time it will take for him to prevent a lockdown from ever occurring.

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

The first line contains N, the number of cows on Farmer John's farm.
Then N lines follow. The kth line contains a bitstring equal to the Farm ID number of the kth cow on Farmer John's farm.

No cow's Farm ID number is empty, and the total length of all Farm ID numbers is at most 106.

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

Output the minimum number of seconds Farmer John needs to spend to ensure that a lockdown will never occur.

SAMPLE INPUT:

3
1
1
1

SAMPLE OUTPUT:

5

This sample satisfies the constraints for the first subtask.

We can make a lockdown impossible in 5 seconds by adding '0' to the first Farm ID number, '10' to the second Farm ID number, and '11' to the third Farm ID number, making the Farm ID numbers '10', '110', and '111'.

You can prove that this cannot be done in 4 or fewer seconds. For example, if you leave the Farm ID numbers as they are, then all 3 cows have the same Farm ID number '1', so when Bessie hears it it will always be the Farm ID number of another cow.

As another example, if you spend just 2 seconds to add '0' to the second Farm ID number and '1' to the third Farm ID number, then the Farm ID numbers are '1', '10', and '11', and so the second and third cows, when saying their Farm ID numbers, might stop in the middle and just say '1', which would be the Farm ID number of the first cow.

SAMPLE INPUT:

3
1
11
111

SAMPLE OUTPUT:

2

We can make a lockdown impossible in 2 seconds by adding '0' to the first two Farm ID numbers, making the Farm ID numbers '10', '110', and '111' like before. You can prove that this cannot be done in 1 second.

SAMPLE INPUT:

3
1
1
11

SAMPLE OUTPUT:

4

We can make a lockdown impossible in 4 seconds by adding '00' to the first Farm ID number and '01' to the second Farm ID number. You can prove that this cannot be done in 3 or fewer seconds.

SAMPLE INPUT:

5
0
01
0011
010
01

SAMPLE OUTPUT:

6

SAMPLE INPUT:

14
0
1
1
0
1
0
1
1
1
1
1
0
0
1

SAMPLE OUTPUT:

41

This sample satisfies the constraints for the first subtask.

SCORING:

Inputs 6-7: All Farm ID numbers have length exactly 1.
Inputs 8-15: N≤102and the total length of the Farm ID numbers does not exceed 103.
Inputs 16-25: No additional constraints.

Problem credits: Benjamin Qi

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

咨询一对一备赛规划

USACO竞赛获奖需具备这三大能力!参加USACO竞赛具有什么意义?

无论你是初学编程的新手还是已经具备不俗实力的高手,USACO竞赛体系都值得你认真了解。USACO是面向全球信息学爱好者开放的一项重要赛事,是国际奥赛信息学竞赛的预选比赛。每年的USACO赛季时间大致在12月至次年3月,而在5月则会选出国家集训队员。

USACO竞赛学习关键

提升算法分析能力:

- 学生需要能够根据题目条件快速判断所需的算法,并将解题过程梳理成步骤。

- 这需要对各种算法有深入的理解和熟练的运用,包括贪心算法、动态规划、图论等。

增强代码编写能力:

- 关键的能力之一是将思考步骤转换成代码,通过计算机进行求解。

- 学生需要掌握编程语言的基础知识,并能够熟练运用各种数据结构和算法来实现解题思路。

具备数理逻辑能力:

- 数理逻辑能力在编程中至关重要,能够帮助学生更好地完成算法运算。

- 这包括对问题的分析能力、逻辑思维能力以及数学推理能力的培养。

参加USACO竞赛具有什么意义?

刷题练习:

USACO的月赛和公开赛试题都是信息学奥赛的经典之一。国内一些命题也会参考USACO的历史原题,因此USACO可以作为刷题练习的良好资源。对于有志于在国内信息学奥赛中取得好成绩的选手来说,刷USACO题目是非常推荐的。

丰富赛事经验:

国内信息学奥赛每年只有一次,而且很多选手缺乏足够的赛事经验。在赛场上,缺乏经验可能影响选手发挥,一旦失误往往要等待下一年才有机会弥补。USACO每年有4场比赛,且每个等级都有对应的题目,如果实力足够,可以从青铜直接晋级到白金。USACO的题目难度和质量相比国内信息学奥赛也更具挑战性,对于想要增加赛事经验的选手来说,USACO是一个很好的选择。

出国履历:

USACO的官网展示了IOI 2023国际信息学奥赛和EGOI 2023欧洲女子信息学奥赛的美国队成员名单。在USACO中取得好成绩,特别是进入白金等级,可以增加参加国际奥赛的机会。华人在USACO中取得突出成绩的例子很多,这对于想要出国参赛的选手来说是一个很好的参考和鼓舞。

【扫码免费领取】USACO真题+一对一备考规划!

预约最新真题讲座、课程详情可添加下方顾问老师咨询

USACO比赛是全英文吗?不同基础的学生如何备考USACO竞赛?附入门USACO竞赛必读书籍!

USACO是美国选拔国际奥林匹克信息学竞赛(IOI)队员的重要选拔赛事,现如今已对全球考生开放。在USACO竞赛中获得金奖或铂金奖,对于申请藤校的计算机科学专业来说,是一个强有力的杀手锏。

此外,对于学生未来的就业也有很大的帮助,大型科技公司往往会优先录取USACO竞赛铂金奖项获得者。因此,USACO这一备受关注且含金量高的热门计算机竞赛备受家长认可。

USACO比赛是英文吗?

18 年之前,比赛试题只提供英语、法语、俄语等版本,没有中文版。18年2月份晋级赛开始,试题开始出现官方中文版本。23年1月份开始又取消的中文版

不同基础的学生如何备考USACO竞赛?

没有编程基础的同学:

- 建议从Python或者Java入手,这两种编程语言上手较快。

- 学习内容主要包括数据结构和编程语法,并配合一定强度的练习和老师讲解。可以参加铜升银选拔等初级竞赛来提高自己的编程能力。

有编程基础的同学如何备考:

- 对于已有编程基础的学生,可以选择C/C++或者Python作为主要编程语言,学习更深入的算法知识。

- 加强算法练习和真题训练,可以通过解决一些中等难度的题目来提高自己的编程和解题能力。

有相关参赛经验的同学如何备考:

- 在掌握数据结构和编程语法的基础上,需要系统地学习一些常见的算法,比如贪心算法、动态规划、图算法等。

- 大量练习官方的金和白金级别的真题,这是提高解题能力和熟悉竞赛考点的有效方式。

不论基础如何,备考USACO竞赛都需要掌握相应的编程语言、数据结构和算法知识,并进行大量的练习和真题训练。

USACO竞赛书籍

《USACO算法书》

本书是为零基础开始学习USACO竞赛必备书籍,为同学们参加USACO竞赛各级别提供了一系列有价值的参考资料,是备考USACO竞赛一站式指南。

《编程竞赛手册》

这是一本几乎涵盖了竞赛类编程所有算法和知识指南,将帮助同学们体系化知识并有详尽的解释,对于算法入门者系统掌握算法基础非常有帮助。

《哈希表》

主要作用在于高效查找。在编程实现中,常常面临着两个问题:存储和查找,存储和查找的效率往往决定了整个程序的效率。

《竞赛编程》

本书从竞赛编程技巧、数据结构和库、图标、字符串处理等方面来介绍USACO竞赛。

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

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

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

USACO竞赛不同等级难度如何?USACO竞赛考多少分对申请有用?

USACO考试得分对于未来的发展具有重要意义,得分与国际信息学奥林匹克竞赛(IOI)金牌、进入USACO国家集训队等成就挂钩,不同等级的分数也会在申请名校时产生不同程度的加分效果。

USACO竞赛分为四个等级:青铜、白银、黄金和白金。下面我会对每个等级进行详细的分点概括和扩充。

青铜等级:

- 进入USACO注册账号即为青铜级别。

- 要求具备基本编程基础,至少熟练掌握一种编程语言。

- 大部分初次参赛选手在第一次考试中都能晋级为白银等级。

白银等级:

- 参赛学生需要具备基本的问题解决能力。

- 必须掌握简单的算法,如贪心算法、递归搜索等。

- 需要了解基础的数据结构。

- 挑战在于寻找更优秀的算法,以使程序在规定时间内运行完毕。

黄金等级:

- 难度提升,要求选手具备一定的算法基础。

- 必须理解一些抽象的方法,如最短路径、动态规划等。

- 对数据结构要有比较深入的了解。

白金等级:

- 最高等级,对选手的编程基础和算法水平有着较高的要求。

- 需要对算法有深入的理解,并能够熟练运用。

- 要求选手具备较高的编程能力,能够解决复杂的问题和挑战。

USACO竞赛考多少分有用?

IOI金牌(10分):

是最高级别的成就,可极大增加进入MIT、Stanford、Harvard等名校的录取机会。

进入USACO国家集训队(8分):

是令人瞩目的成就,对申请MIT、Stanford、Princeton等顶尖大学有显著的助推作用。

进入USACO铂金级(Platinum Division,7分):

在申请CMU、Georgia Tech、UC Berkeley等名校时,同样能起到重要的加分作用,是非常棒的成就。

进入USACO黄金级(Gold Division,6分):

对申请像UC Berkeley、UCLA、Georgia Institute of Technology等好学校有一定的加成效果,是相当不错的结果。

进入USACO白金级(Silver Division,4.5分):

虽然分数相对较低,但在申请很多大学时也是一个明显的亮点,能够为申请者增加竞争优势。

USACO考试成绩不仅能够展现个人的编程能力和算法水平,还可以在申请大学时成为加分项,提升录取的机会和竞争力。

【扫码免费领取】USACO真题+一对一备考规划!

预约最新真题讲座、课程详情可添加下方顾问老师咨询

一文搞懂USACO竞赛晋级常见问题!USACO竞赛想要达到铂金需要多长时间?

近年来,随着人工智能和编程教育的普及,USACO竞赛的参赛人数水涨船高,热度与日俱增。对于那些希望申请美国顶尖大学本科或研究生项目以及优质夏校的学生来说,获得USACO黄金或铂金级别奖项将极大地提升他们的竞争力。

USACO竞赛晋级标准

考试方式:在规定的时间内完成若干编程题目,提交自己的代码。系统会自动给出评分。

分值和总分:每个问题的分值都是333.333分,总分是1000分。如果有选手达到满分,考试系统会当场评定直接晋级。

晋级标准:如果没有选手在考试中达到满分晋级,他们需要等待赛后公布分数线,根据分数线来评判自己是否晋级到下一个等级。

竞赛等级:USACO竞赛一共有4个等级,包括青铜级、白银级、黄金级和铂金等级。

升级标准:根据前两场的晋级情况来看,USACO竞赛每场的升级标准在700~800分之间。等级越高,升级难度越大。

USACO竞赛的晋级标准主要取决于每场竞赛的分数线,一般在700~800分之间。晋级到更高级别的等级需要表现更加突出和优异。

USACO竞赛想要达到铂金需要多长时间?

要达到USACO的铂金级别需要长时间的学习和积累。以下是一些步骤和时间估计:

第一阶段:建立基础(约1-2年)

- 初中阶段的学生可以从编程基础开始学习,包括语法、数据类型和基本算法。

- 初步了解编程语言,例如Python或C++。

- 开始解决一些简单的编程问题,培养问题解决能力。

第二阶段:深入学习(约3个月)

- 在已经建立基础的情况下,学生可以开始学习更复杂的算法和数据结构。

- 深入理解常见的算法,如贪心算法、动态规划等。

- 学习更高级的编程技巧,如优化程序性能和处理大数据量等。

第三阶段:参加USACO训练

- 参加USACO训练营或自学USACO官方指导教程。

- 解决大量USACO官方练习题目,逐步提高解题能力。

- 参加USACO比赛,积累竞赛经验并适应竞赛环境。

第四阶段:提高水平(约1-2年)

- 通过不断练习和参加比赛,逐渐提高解题速度和准确度。

- 学习高级算法和数据结构,如图论、网络流等。

- 深入理解计算机科学领域的相关知识,包括算法分析和复杂性理论等。

【扫码免费领取】USACO真题+一对一备考规划!

预约最新真题讲座、课程详情可添加下方顾问老师咨询