2026 年 USACO竞赛 第三场比赛金奖组问题三—Random Tree Generation

Suppose the function randint(l,r) returns an integer independently and uniformly at random from the range [l,r].

Bessie generates a random labeled tree on N vertices (2≤N≤2⋅105) using the following two-step process:

1.Start with vertices labeled 1 through N. For each i from 2 to N, add an edge between vertex i and randint(1,i−1).

2.Choose a permutation p1,p2,…,pN of {1,2,…,N} uniformly at random. Relabel every vertex v as pv.

Now, Farmer John is looking at the edge set of the final tree and wants to know the probability that the two-step process above produces a tree with exactly this edge set. Can you determine this probability modulo 109+7?

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

The input consists of T(1≤T≤10) independent inputs. Each input is specified as follows:

The first line contains N.

The next N−1 lines contain the edges of the tree specified by two space-separated integers u and v (1≤u,vN). It is guaranteed that these edges induce a tree.

It is guaranteed that the sum of N across all tests does not exceed 5⋅105.

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

For each test, output the probability modulo 109+7 on a new line (note that the output probability is a ratio of integers, so you will want to print the result of this division when working modulo 109+7).

SAMPLE INPUT:

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

SAMPLE OUTPUT:

1
333333336
83333334
55555556

The probabilities are 1, 1/3, 1/12, 1/18.

First test: There is only one tree on N=2 vertices, so the probability of generating it is just 1.

Second test: there are three trees on N=3 vertices, and each of them is equally likely to have been generated by the process above. And 1/3≡333333336(mod 109+7).

SCORING:

Input 2-3: N≤8
Inputs 4-9: N≤2000
Inputs 10-21: No additional constraints.

Problem credits: Benjamin Qi

2026 年 USACO竞赛 第三场比赛金奖组问题二—Picking Flowers

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

Farmer John's farm structure can be represented as a connected undirected graph with N vertices and M unweighted edges (2≤N≤2⋅105,N−1≤M≤2⋅105
). Initially, Farmer John is at his barn, represented by farm 1.

Initially, farms s1,s2,…,sK contain flower fields and farms d1,d2,…,dL are destination farms. FJ calls a path pretty if:

It starts at farm 1.
It ends at some destination farm x.
There is no shorter path starting at farm 1and ending at farm x.
FJ visits all flower fields along the way.

FJ can wave his magic wand and make up to one more farm contain a flower field (if it doesn't already). However, FJ isn't very decisive. For farms f numbered 2 through N, after FJ temporarily makes farm f contain a flower field, determine if there exists a pretty path.

Note that there are multiple test cases, and each case must be treated independently.

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

The first line contains T (1≤T≤100), the number of independent test cases.

The first line of each test case contains N, M, K, and L(0≤KN−1,1≤LN−1).

The following line contains s1,s2,…,sK ( 2≤ si N, siare all distinct ).

The following line contains d1,d2,…,dL (2≤diN, di are all distinct).

The following M lines contain u and v, denoting there is an undirected edge between farms u and v. All edges are considered to have equal length. It is guaranteed that there aren't any multi-edges or self loops.

It is guaranteed that both the sum of N and the sum of M do not exceed 106 over all test cases.

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

For each test case, output a binary string of length N−1. The i'th character in the string should be 1 if the answer holds true for the (i+1)'th farm.

SAMPLE INPUT:

1
7 7 0 1

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

SAMPLE OUTPUT:

111110

Since 5 is the only destination farm, the answer holds true if the i'th farm lies on any shortest path from 1 to 5.

There are two shortest paths from 1 to 5, which are 1→2→3→4→5 and 1→2→3→6→5.

Since there are no farms that already contain flower fields, the answer for farm i
holds true if farm i lies on at least one of the two aforementioned paths.

SAMPLE INPUT:

1
6 6 0 2

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

SAMPLE OUTPUT:

11010

There are two destination farms: 5 and 3. Since there are no farms that already contain flower fields, the i'th farm must lie on a shortest path to either 5 or 3. Since farm 2 lies on a shortest path to farm 5, so the answer holds for farm 2. Trivially, farm 3 lies on the shortest path to farm 3 and farm 5 lies on the shortest path to farm 5.

SAMPLE INPUT:

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

SAMPLE OUTPUT:

111
000
1011

For the first test case, the answer holds true for the i'th farm if FJ can pass through farm i, farm 2, and farm 3 (in no particular order) on some shortest path to farm 4. It can be shown that the answer holds true for all farms.

SCORING:

Inputs 4-6: K=0and L=1
Inputs 7-9: K=0
Inputs 10-23: No additional constraints

Problem credits: Chongtian Ma

2026 年 第三场比赛——最终结果

USACO 2026赛季的第三场比赛涵盖了涵盖多种技术和难度的算法编程问题。

在为期四天的比赛期间,共有7302名不同用户登录了该活动。共有5084名参与者提交了至少一个解决方案,来自100+个不同国家。3203名参与者来自美国,中国、加拿大、韩国、马来西亚、印度和新加坡的参与度较高。

总共有14003份评分提交,按语言分类如下:

8997 C++17
2349 Python-3.6.9
1479 Java
1052 C++11
99 C
27 Python-2.7.17

以下是白金、金、银和铜三项比赛的详细成绩。 你还可以找到每个问题的解决方案和测试数据,点击任意 问题你可以练习在“分析模式”下重新提交解答。

USACO 2026年 第三场 比赛,白金奖

白金组共有300名参与者,其中243名是大学预科生。

1 All Pairs Shortest Paths
查看问题 | 测试数据 | 解决方案
2 Blast Damage
查看问题 | 测试数据 | 解决方案
3 Min Max Subarrays II
查看问题 | 测试数据 | 解决方案

USACO 2026年 第三场 比赛,金奖

金组共有1245名参与者,其中910名是大学预科生。所有在本比赛中得分达到750分或以上的选手将自动晋级白金组。

1 Good Cyclic Shifts
查看问题 | 测试数据 | 解决方案
2 Picking Flowers
查看问题 | 测试数据 | 解决方案
3 Random Tree Generation
查看问题 | 测试数据 | 解决方案

USACO 2026年 第三场 比赛,银奖

银组共有2446名参赛者,其中1916人为预科生。所有在本比赛中得分达到700分或以上的选手将自动晋级金组。

1 Clash!
查看问题 | 测试数据 | 解决方案
2 Milk Buckets
查看问题 | 测试数据 | 解决方案
3 Point Elimination
查看问题 | 测试数据 | 解决方案

USACO 2026年 第三场 比赛,铜奖

铜组共有3014名参赛者,其中2374人为大学预科生。所有在本比赛中得分达到700分或以上的选手将自动晋级银组。

1 Make All Distinct
查看问题 | 测试数据 | 解决方案
2 Strange Function
查看问题 | 测试数据 | 解决方案
3 Swap to Win
查看问题 | 测试数据 | 解决方案

结语

我对本季第三场也是最后一场“标准级”竞赛的结果感到满意。从技术层面看,一切进展非常顺利(我们在第二场竞赛中发现负载相关问题后对基础设施进行了升级,这些改进似乎取得了显著成效)。尽管本次竞赛的题目难度依然极高,但多个组别的大量选手均获得了晋级。我和USACO团队仍需投入超出理想时长的精力处理学术诚信相关事务(例如手动审核提交内容、向校方负责人提交报告等),但这些工作对于维持我们与他人所期待的竞赛高标准诚信至关重要。生成式人工智能加剧了这一挑战,但我们希望通过加强监考措施来缓解这一问题——我们期待本季最后一场邀请制监考竞赛能够顺利进行。

对于尚未晋级的选手,请记住:实践越多,你的算法编码能力就会越强——请坚持下去!USACO竞赛旨在挑战最顶尖的学生,要想脱颖而出需要付出大量努力。现在,你还可以通过"分析模式"重新提交解题方案,并从判题服务器获得反馈,以帮助修复代码中的错误。

2026 年 USACO竞赛 第三场比赛金奖组问题一—Good Cyclic Shifts

For a permutation p1,p2,…,pN of 1…N (1≤N≤2⋅105), let f(p)=. A permutation is good if it can be turned into the identity permutation using at most f(p) swaps of adjacent elements.

Given a permutation, find which cyclic shifts of it are good.

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

The input consists of T (1≤T≤105) independent tests. Each test is specified as follows:

The first line contains N.

The second line contains p1,p2,…,pN (1≤piN), which is guaranteed to be a permutation of 1…N.

It is guaranteed that the sum of N over all tests does not exceed 106 .

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

For each test, output two lines:

On the first line, output the number of good cyclic shifts k.

Then output a line with k space-separated integers s (0≤s<N) in increasing order, meaning that p is good when cyclically shifted to the right s times.

SAMPLE INPUT:

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

SAMPLE OUTPUT:

0

2
0 1
5
0 1 2 3 4

Consider the second test case, where p=[1,2,4,3].

f(p)=(|1−1|+|2−2|+|4−3|+|3−4|)/2=1. Since p can be turned into the identity permutation in one move by swapping p3 and p4, p is good.

Cyclically shifting p to the right 1 time, we get q=[3,1,2,4]. f(q)(|3−1|+|1−2|+|2−3|+|4−4|)/2=2. Since q can be turned into the identity permutation in two moves by swapping q1 two steps forward, q is good.

It can be seen that the other two cyclic shifts are not good.

SCORING:

Input 2: N≤10
Inputs 3-5: T≤10,N≤2000
Inputs 6-11: No additional constraints.
Problem credits: Akshaj Arora

2026 年 USACO竞赛 第三场比赛白金组问题三—Min Max Subarrays II

You are given integers N,Q (1≤N,Q≤2⋅105) and Q constraints represented by four integers ti,li,ri,ki (1≤ti≤2,1≤li≤ri≤N,0≤ki≤109,all ki are distinct).

Construct an array a consisting of N integers between 0 and 109 such that for all 1≤i≤Q, mina[li...ri]=ki if ti=1 and maxa[li...ri]=ki if ti=2. If multiple valid arrays exist, print any. If no valid array exists, print −1.

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

The first line contains an integer T (1≤T≤104) representing the number of independent test cases.

For each test case, the first line contains two integers N,Q.

The next Q lines each contain 4 integers ti li ri ki.

It is guaranteed that neither the sum of N nor the sum of Q over all test cases exceed 2⋅105.

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

For each test case, if a valid array exists, output N space-separated integers a1…aN on a new line. Otherwise, print −1.

SAMPLE INPUT:

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

SAMPLE OUTPUT:

-1
1 2
0 3 0 0

In the first test case, the answer is −1 because the minimum value of the array cannot be both 1 and 2 at the same time.

In the second test case, a[1...2] has a minimum of 1 at a[1] in the sample output, satisfying the first constraint. Since a[2]=2, the second constraint is also satisfied.

In the third test case, there are multiple solutions. For instance, the array [4,3,2,1]
would also be accepted.

SAMPLE INPUT:

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

SAMPLE OUTPUT:

1 2
-1
3 3 0 2 2
1 5 2 6

In the second test case, the array [3,5,1] satisfies the first constraint but not the second constraint. Contrarily, the array [3,1,1] satisfies the second constraint but not the first constraint. It can be proven that no array can satisfy both constraints at the same time, hence the answer is −1.

For all other test cases, it can be proven that the constructed array satisfies all Q
constraints.

SCORING:

Inputs 3-4: N,Q≤100 and all ti within the same test case are equal
Inputs 5-6: all twithin the same test case are equal
Inputs 7-10: N,Q≤100
Inputs 11-14: No additional constraints.

Problem credits: Charlie Yang

2026 年 USACO竞赛 第三场比赛白金组问题二—Blast Damage

Bessie is playing a video game where she needs to defeat a line of N enemies with initial HPs given by the list v1…vN (1≤N≤2⋅105,0≤vi≤109). In one attack, she can perform the following sequence of steps:

Choose i such that the ith enemy is still alive (that is, vi>0).
Deal one damage to the ith enemy and all enemies adjacent to it that are still alive. Specifically, for each j∈[max(i−1,1),min(i+1,N)], if vj>0, subtract one from vj.

Help Bessie determine the minimum number of attacks she needs to defeat all enemies (that is, reduce all vi to 0).

Additionally, you are given a parameter M (0≤M≤2). If M>0, please output a construction achieving the minimum number of attacks with a small number of runs, where a run consists of attacking the same enemy consecutively.

Let R be the number of runs in your construction. Your construction should be in the following format: output R on its own line, followed by R lines each containing two integers i and r (1≤iN,0≤r≤109), meaning that Bessie attacks the i-th enemy r times consecutively.

Depending on the value of M, R must satisfy one of the following constraints:

M=1: R≤2N(it can be proven that a construction always exists).
M=2: R≤f(N), where f(N) is the maximum minimum number of runs over all lists of length N.

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

Each input consists of T (1≤T≤105) independent tests. The first line contains T
and M.

Each test is specified as follows:

The first line contains N.

The second line contains v1…vN.

It is guaranteed that the sum of N over all tests does not exceed 106 .

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

For each test, output the minimum number of attacks on the first line.

Then if M>0, output R+1 additional lines as specified above. Any valid construction will be accepted.

SAMPLE INPUT:

2 0
1
10
3
6 1 7

SAMPLE OUTPUT:

10
12

For the second test, you can first perform one attack on the middle enemy. Then, in any order after that, perform five attacks on the first enemy and six attacks on the last enemy.

SAMPLE INPUT:

2 1
1
10
3
6 1 7

SAMPLE OUTPUT:

10
2
1 0
1 10
12
4
2 1
1 5
3 2
3 4

This output receives credit because R=2≤2 for test 1 and R=4≤6 for test 2.

SAMPLE INPUT:

2 2
1
10
3
6 1 7

SAMPLE OUTPUT:

10
1
1 10
12
3
2 1
3 6
1 5

This output receives credit because R=1≤f(1) for test 1 and R=3≤f(3) for test 2.

SCORING:

Inputs 4-7: M=0
Inputs 8-11: M=1
Input 12-13: M=2
Problem credits: Benjamin Qi

2026 年 USACO竞赛 第三场比赛白金组问题一—All Pairs Shortest Paths

You have a bunch of triangular regions that tessellate an infinite 2D plane. The tesselation is defined as follows (see the diagram for a better understanding):

Recall that Euler's formula states that eix=cos(x)+isin(x) for real x. First, draw a vertex at x+yexp(πi/3)on the complex plane for all integers x,y.

Then for every three vertices from the step above forming an equilateral triangle with side length 1, draw the edges forming its border. Additionally, draw a vertex at the center of the triangle and edges from the center of the triangle to each of three outer vertices.

You are given N (2≤N≤2⋅105) input points, each of which lies strictly within some region (i.e., not on any vertex or edge). For any pair of the input points, define the distance between them to be the smallest number of edges crossed when drawing a path from one point to the other that doesn't pass through any vertex.

Output the sum of all N(N−1)/2 pairwise distances between the input points.

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

The first line contains T(T≥1), the number of independent tests. Each test is specified as follows:

The first line contains N.

The next N lines each contain three integers x, y, and z(0≤x,y<106,0≤z<12) representing a point at x+yexp(πi/3)+ϵ⋅exp((1+2z)πi/12) on the complex plane (ϵ
being a small positive number).

It is guaranteed that the sum of N over all tests doesn't exceed 2⋅105.

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

For each test, output the sum of all N(N−1)/2 pairwise distances on a new line.

SAMPLE INPUT:

6
2
0 0 0
0 0 0
2
0 0 0
1 1 7
2
0 0 0
0 0 6
3
0 0 1
0 0 5
0 0 9
2
0 2 11
1 1 1
2
2 0 11
1 1 1

SAMPLE OUTPUT:

0
3
6
12
2
6

The second test is illustrated below:

The vertex at x+yexp(πi/3) is labeled with (x,y) for each x∈[−1,2],y∈[−1,2].

Dots are drawn at the vertices mentioned above as well as the vertices that are the centers of each equilateral triangle.

The triangular region containing (x,y,z)=(0,0,0) is highlighted in green.

The triangular region containing (x,y,z)=(1,1,7) is highlighted in blue. Note that 15π/12=225.

An example path from the first region to the second crossing three edges is drawn.

SCORING:

Inputs 2-5: N≤10, 0≤x,y<5
Inputs 6-13: N≤10
Inputs 14-21: T=1
Problem credits: Benjamin Qi

2025-2026赛季USACO第三场月赛各等级考情分析!附第三场真题+解析+参考答案!

USACO 2025–2026 赛季第三场月赛(2026年2月举行)已落下帷幕。作为本季倒数第二场常规赛,其题目风格进一步印证了 USACO 官方“淡化算法模板、强化逻辑推导与数学抽象”的出题趋势。本文将从分数线预测、难度评估、考点拆解、备赛建议四大维度,为各等级选手提供精准复盘。

USACO第三场月赛各等级详细分析

铜级篇(Bronze)

晋级分数线预测

赛季 第一场 第二场 第三场(预估)
2025–26 700 700 700–750

难度分析

这次银级的难度,和第二场比赛差不多。也没有太多涉及重点算法,对大家逻辑思维推理、数据结构使用要求很高。晋级难度和满分难度,比上一场稍微难点。如果大家学过金级的内容,可能会更容易得分。

考点分析

第一题【Greedy + Simulation + Priority queue + Queue + Prefix Sum + Binary Search】

这道题考察的点比较多。从Greedy去考虑,肯定会把手中win牌cost最小的出出去,如果没有win牌的,就出非win中cost最小的。但是按照这个策略去simulation(手上的牌用Priority queue,等待的牌用Queue),会发现t太大,会有time out的问题。可以多看几个例子,会发现后面一定会有环出现,所以找环就是我们需要重点解决的。

这里一个很重要的点,就是当所有牌都进来一遍以后,手上肯定有h-1张牌是永远打不出去的,也就是优先级最低的h-1张(优先级高指的是win是1cost小的)。后面的状态是这样的:这h-1张牌一直在手里拿着,每次另外一张牌A出去,进行一张牌B;B出去进来C,C出去进来D……找到这个规律以后,我们可以分两步来模拟:第一步先模拟n次,确保此刻一定已经入环了;第二步再从该状态开始,模拟n-h+1次(环的长度)。这两次模拟,都去记录cost和wincard的prefix sum,后面计算t时,可以在这些数组中binary search,找<=t的最大值即可。

这道题的贪心策略很简单,但是需要发现核心的h-1张牌一定会一直在手心,后面就是常规的算法优化,总体是三道题中最简单的。

第二题【Math+ Segment Tree】

这道题首先是数学公式的推导。最后池子里的水量,就是a[n]*第n个桶倒了几次。题目给我们列出来了每个桶flip的时间,这其实很重要,可以发现从某个时刻s开始,会以周期t进行flip。第一个桶的s是a[1]+1,先花a[1]时间装满,然后下一个时刻flip;第一个桶的t也是a[1]+1,因为下一轮还是等a[1]时间装满,再去flip。后面桶的t和s都可以推导出来,比如考虑第i-1和第i个桶的关系。第i-1个桶,需要装ceil(a[i]/a[i-1])次,才能把i装满,所以t[i]=t[i-1]*time,s[i]=s[i-1]+(time-1)*a[i-1]+1。这里time-1是因为在s[i-1]时刻已经完成了一次,最后+1是因为再过一个时刻,才会开始flip。有了这些递推公式,就可以得到第n个桶的s和t,对于任意时刻T,可以计算第n个桶倒了(T-s[n])/T[n]+1次到水池。实现的过程,注意数据范围,可能会很大,一旦超过1e18,可以直接输出0结束。

不过每次查询前,还有更新操作,这会导致第i和第i-1个桶的t发生改变,i-1后面所有桶的s发生改变。每次重新计算会超时,这里可以用金级的【Segment Tree】去优化,写一个struct和combine方法,实现【单点更新】和【区间查询】。这部分对大家要求很高,不过每次直接计算,也可以拿到40%的分数。总体要拿满分很难,不过只要自己去推导找规律,还是可以拿到部分分数的。

第三题【Greedy + Parity Constraints】

又是一道贪心构造、奇偶校验题,和第一场第三题、第二场第一题,是一个类型。因为y可以随便交换,所以不用关心x和y的绑定关系,x和y可以分开讨论。

先看所有x,比如x数值有1、2、3、4、7、8、10、12、13、14,因为消除的关键是距离为1,所以x必须相等或者相差1。离得远的x,肯定不能进行匹配,所以可以把x分段进行考虑,【1、2、3、4】、【7、8】、【10】、【12、13、14】。每个x有3种用途,和x-1匹配,和x+1匹配,自己内部匹配(必须剩余偶数个)。如果段内只有一个x,比如【10】,个数是奇数的话,肯定是NO。段内元素不止一个,比如【1、2、3、4】,可以贪心得从最左侧开始匹配。虽然具体数量不能确定,但是可以有一个奇偶性和范围。奇偶性指的是,比如【1、2、3、4】出现的个数是【4,5,3,4】,那么第一个往右的边必须是even(留even个内部匹配),第二个往右的边必须是odd,第三个是even(因为左边用了它odd个),校验最后一个位置留给自己内部的是否是even。这个规程中,可以算出来最小值(even是1odd是0)和最大值(尽可能往右匹配),也就是x方向能形成的最小、最大匹配数。

Y方向也是类似处理,关键的一步就是它们的合并。比如x方向匹配了[3,9],y方向匹配了[2,8],总数n是20,也就是一共需要n/2个匹配。注意x方向匹配成功的就是x相差1的,没有匹配成功的,就是x相等的;y中匹配成功的,就是y相差1的,没有匹配成功的,就是y相等的。所以只要满足它们相加的范围,能覆盖到n/2就可以,这里[5,17]可以包含10。不过还要检查奇偶性,因为[5,17]只是里面所有的odd可以,10是even,所以还是失败。

总体这道题应该是三道题中比较难的,最近三场都有类似的贪心构造问题,而且无一例外都围绕着【奇偶校验】,大家要学会多从这个方向去考虑问题。

备考启示

不要依赖模板:Q2 无标准算法,必须通过小样例找规律;

重视大数处理:输入可达 10^{200000}10200000 ,需用字符串+模运算;

贪心需证明:Q1/Q3 的贪心策略必须确保“局部最优=全局最优”。

银级篇

晋级分数线预测

赛季 第一场 第二场 第三场(预估)
2025–26 700 700 700–750

尽管无复杂算法,但逻辑链条长、边界条件多,满分仍难。

三题核心考点

第一题【Greedy + Simulation + Priority queue + Queue + Prefix Sum + Binary Search】

这道题考察的点比较多。从Greedy去考虑,肯定会把手中win牌cost最小的出出去,如果没有win牌的,就出非win中cost最小的。但是按照这个策略去simulation(手上的牌用Priority queue,等待的牌用Queue),会发现t太大,会有time out的问题。可以多看几个例子,会发现后面一定会有环出现,所以找环就是我们需要重点解决的。

这里一个很重要的点,就是当所有牌都进来一遍以后,手上肯定有h-1张牌是永远打不出去的,也就是优先级最低的h-1张(优先级高指的是win是1cost小的)。后面的状态是这样的:这h-1张牌一直在手里拿着,每次另外一张牌A出去,进行一张牌B;B出去进来C,C出去进来D……找到这个规律以后,我们可以分两步来模拟:第一步先模拟n次,确保此刻一定已经入环了;第二步再从该状态开始,模拟n-h+1次(环的长度)。这两次模拟,都去记录cost和wincard的prefix sum,后面计算t时,可以在这些数组中binary search,找<=t的最大值即可。

这道题的贪心策略很简单,但是需要发现核心的h-1张牌一定会一直在手心,后面就是常规的算法优化,总体是三道题中最简单的。

第二题【Math+ Segment Tree】

这道题首先是数学公式的推导。最后池子里的水量,就是a[n]*第n个桶倒了几次。题目给我们列出来了每个桶flip的时间,这其实很重要,可以发现从某个时刻s开始,会以周期t进行flip。第一个桶的s是a[1]+1,先花a[1]时间装满,然后下一个时刻flip;第一个桶的t也是a[1]+1,因为下一轮还是等a[1]时间装满,再去flip。后面桶的t和s都可以推导出来,比如考虑第i-1和第i个桶的关系。第i-1个桶,需要装ceil(a[i]/a[i-1])次,才能把i装满,所以t[i]=t[i-1]*time,s[i]=s[i-1]+(time-1)*a[i-1]+1。这里time-1是因为在s[i-1]时刻已经完成了一次,最后+1是因为再过一个时刻,才会开始flip。有了这些递推公式,就可以得到第n个桶的s和t,对于任意时刻T,可以计算第n个桶倒了(T-s[n])/T[n]+1次到水池。实现的过程,注意数据范围,可能会很大,一旦超过1e18,可以直接输出0结束。

不过每次查询前,还有更新操作,这会导致第i和第i-1个桶的t发生改变,i-1后面所有桶的s发生改变。每次重新计算会超时,这里可以用金级的【Segment Tree】去优化,写一个struct和combine方法,实现【单点更新】和【区间查询】。这部分对大家要求很高,不过每次直接计算,也可以拿到40%的分数。总体要拿满分很难,不过只要自己去推导找规律,还是可以拿到部分分数的。

第三题【Greedy + Parity Constraints】

又是一道贪心构造、奇偶校验题,和第一场第三题、第二场第一题,是一个类型。因为y可以随便交换,所以不用关心x和y的绑定关系,x和y可以分开讨论。

先看所有x,比如x数值有1、2、3、4、7、8、10、12、13、14,因为消除的关键是距离为1,所以x必须相等或者相差1。离得远的x,肯定不能进行匹配,所以可以把x分段进行考虑,【1、2、3、4】、【7、8】、【10】、【12、13、14】。每个x有3种用途,和x-1匹配,和x+1匹配,自己内部匹配(必须剩余偶数个)。如果段内只有一个x,比如【10】,个数是奇数的话,肯定是NO。段内元素不止一个,比如【1、2、3、4】,可以贪心得从最左侧开始匹配。虽然具体数量不能确定,但是可以有一个奇偶性和范围。奇偶性指的是,比如【1、2、3、4】出现的个数是【4,5,3,4】,那么第一个往右的边必须是even(留even个内部匹配),第二个往右的边必须是odd,第三个是even(因为左边用了它odd个),校验最后一个位置留给自己内部的是否是even。这个规程中,可以算出来最小值(even是1odd是0)和最大值(尽可能往右匹配),也就是x方向能形成的最小、最大匹配数。

Y方向也是类似处理,关键的一步就是它们的合并。比如x方向匹配了[3,9],y方向匹配了[2,8],总数n是20,也就是一共需要n/2个匹配。注意x方向匹配成功的就是x相差1的,没有匹配成功的,就是x相等的;y中匹配成功的,就是y相差1的,没有匹配成功的,就是y相等的。所以只要满足它们相加的范围,能覆盖到n/2就可以,这里[5,17]可以包含10。不过还要检查奇偶性,因为[5,17]只是里面所有的odd可以,10是even,所以还是失败。

总体这道题应该是三道题中比较难的,最近三场都有类似的贪心构造问题,而且无一例外都围绕着【奇偶校验】,大家要学会多从这个方向去考虑问题。

金级篇:数学为王,算法为器

晋级分数线预测

赛季 第一场 第二场 第三场(预估)
2025–26 800 650 700–750

Q2/Q3 极难,预计 700 分即可晋级,但 800+ 才具竞争力。

三题核心考点

第一题【BIT + Greedy + Rotation】

这道题要求处理一个排列经过循环位移后的某种最优性问题。从代码实现看,核心在于通过树状数组(BIT)高效维护逆序对或某种位置贡献。

逻辑抽象:首先利用树状数组计算出初始状态下的统计值和逆序对。

关键转化:题目涉及循环位移(Rotation),代码通过差分数组来维护当序列整体平移时,每个元素对总代价贡献的变化。

贪心策略:通过线性扫描差分数组,找到位移量使得总操作次数最小。这种“将动态位移转化为静态贡献区间”的思路是解决此类问题的金牌套路。

第二题【Shortest Path + Logical Inference】

这是一道非常硬核的图论逻辑题,涉及到多个集合(S 和 D)以及点之间的可达性与顺序约束。

逻辑抽象:代码首先通过 BFS/Dijkstra 建立距离场,并根据输入条件(S 集合与 D 集合)构建出一种拓扑逻辑。

考点攻坚:最难点在于最小值维护和合法性标记的逆序递推。这实际上是在判定是否存在一条满足所有限制条件的路径。

算法体现:代码中利用了大量的条件判定来决定每一个点是否能作为合法路径的一部分。这要求选手对图的遍历顺序和状态传递有极强的控制力。

第三题【Tree Combinatorics + Modular Inverse】

这是一道结合了树形结构、组合数学与大数取模的综合题。

逻辑抽象:题目通过树的结构定义了一种组合计数问题,核心考点在于树的大小与排列组合的关系。

数学核心:代码中预处理了阶乘和逆乘法逆元,并计算了所有子树大小的乘积。这通常指向“树的拓扑排序计数”或类似的概率模型。

这种典型的树形动态规划或组合计数预处理。这要求选手能迅速从题目规则中抽象出与树结构相关的数学通式。

USACO竞赛9.9元体验课+集训班

铜级→银级→金级,金牌导师亲授!

扫码了解详细课程安排

USACO竞赛晋级全流程解析 + 难点突破指南!参加USACO竞赛的核心优势是什么?

USACO作为全球最具影响力的中学生算法竞赛,凭借免费开放、晋级路径清晰、名校高度认可三大优势,已成为中国学生冲刺MIT、Stanford、CMU等顶尖理工院校的重要学术跳板。2026赛季起,USACO进一步优化规则,明确“每场最多晋级一级”,强调持续能力而非单场爆发。

本文将系统梳理 USACO晋级机制、各组别核心难点、能力提升价值,并针对家长关注的“是否适合零基础?是否有专业培训?”问题,提供客观分析与课程建议。

一、USACO晋级流程:两条路径,一个目标

路径1:满分直接晋级(当场生效)

在单场比赛中获得 3000分(三题满分);

系统立即提示晋级;

但2026年起新规:即使满分,也只能升一级(如 Bronze → Silver,不能连跳至 Gold)。

路径2:分数线晋级(赛后公布)

未获满分者,比赛结束后 3–7天内 公布晋级分数线;

通常 700–800分/1000分 可晋级(具体依题目难度浮动);

达标者 下一场月赛 自动进入更高级别。

全年4次机会:
1月、2月、3月、4月(US Open),容错率高,适合稳步提升。

二、USACO四大组别核心难点与突破方向

级别 核心难点 突破建议
Bronze(青铜) - 题意理解偏差
- 模拟逻辑混乱
- 边界条件遗漏
✅ 强化“读题→建模→编码”闭环训练
✅ 刷50+道真题,掌握常见套路(如前缀和、贪心)
Silver(白银) - 数据结构选择错误(如用数组代替队列)
- 暴力超时(未优化复杂度)
- BFS/DFS模板不熟
✅ 精通STL(vector, set, queue)
✅ 掌握二分、双指针、BFS/DFS标准写法
✅ 学会分析时间复杂度(O(n²) vs O(n log n))
Gold(黄金) - 多知识点融合(如DP+图论)
- 高级数据结构实现错误(线段树、并查集)
- 调试困难
✅ 手写核心模板库(Dijkstra、Kruskal、树状数组)
✅ 精读官方题解,学习“最优解思路”
✅ 参加Codeforces保持手感
Platinum(铂金) - 算法创新要求高
- 极致性能优化(卡常数)
- 非标准模型建模
✅ 研究IOI/ICPC真题
✅ 参与算法社区讨论
✅ 培养“从问题本质出发”的构造能力

趋势提醒:

近年 Silver题目难度向Gold靠拢,Bronze也出现简单DP,建议超前学习,不要等晋级后再准备下一级。

三、USACO三大核心优势

1.升学优势:名校“硬通货”

Gold/Platinum证书被 MIT、Stanford、CMU、Caltech 等校视为CS/AI专业核心学术凭证;

在Common App“Honors”栏中可列为 National/International Level Award;

2026新规下,“年度稳定铂金”比“单场冲铂”更具说服力。

2.能力提升:真实问题解决力

题目全部基于实际场景建模(如农场调度、网络路由、基因序列分析);

训练抽象思维 + 工程实现 + 性能优化三位一体能力;

为大学CS课程(算法、数据结构、AI)打下坚实基础。

3.门槛低且免费

全球中小学生均可参赛,无国籍、学校限制;

全程免费,支持C++/Java/Python;

中文社区资源丰富。

备赛的同学可扫码免费领取新赛季USACO全套干货资料⇓

USACO一对一辅导规划!

USACO参赛形式与考试内容说明!这些必须遵守的竞赛规则与常见误区你都知道吗?

美国计算机奥林匹克竞赛(USA Computing Olympiad, USACO)是全球最具权威性的中学生算法编程赛事之一,由美国官方主办,旨在选拔代表美国参加国际信息学奥林匹克(IOI)的国家队成员。因其高含金量、强学术性、公平透明的晋级机制,USACO已成为申请MIT、斯坦福、卡内基梅隆、加州理工等顶尖理工院校的重要加分项。

本文将系统梳理 USACO完整比赛规则、2026–2027赛季时间线、晋级机制、语言选择、常见误区及备赛建议,助你高效规划、合规参赛、稳步晋级。

一、USACO参赛形式与考试内容

基本形式

个人参赛,线上机考;

每场比赛需在4–5小时内完成3道编程题;

题目难度逐题递增(Easy → Medium → Hard);

提交即评分:系统自动运行测试用例,实时反馈得分(0–1000分/题)。

编程语言支持

语言 是否推荐 说明
C++ ✅ 强烈推荐 运行快、STL强大、IO效率高,90%高阶选手使用
Java ✅ 可用 自带大整数、集合类丰富,但IO较慢
Python ⚠️ 仅限铜/银级 语法简洁,但速度慢,黄金级以上易TLE(超时)
C ❌ 不推荐 无标准容器库,开发效率低

 建议:

铜/银级可用Python快速入门;

冲刺黄金及以上,必须转C++。

三、USACO四级晋级体系与核心知识点

USACO采用阶梯式晋级机制,共四个级别,难度逐级跃升:

级别 核心能力要求 典型考点
Bronze(青铜) 编程基础 + 逻辑模拟 - 循环/条件/数组
- 字符串处理
- 暴力枚举、简单贪心
- 基础二分查找
Silver(白银) 算法思维 + 数据结构 - DFS/BFS遍历
- 哈希表(map/set)
- 前缀和、差分
- 双指针、递归
Gold(黄金) 算法综合应用 - 动态规划(背包、区间、树形)
- 图论(Dijkstra、Floyd、MST)
- 并查集、树状数组
Platinum(铂金) 创新与优化能力 - 网络流、复杂DP优化
- 线段树高级应用
- 字符串算法(KMP、哈希)
- 数学构造与组合优化

晋级规则:

满分(3000分) → 当场晋级,可继续挑战上一级(但2026年起每场最多升一级);

未满分 → 赛后按全球排名划线,达标者下一场比赛升组;

无需重复已通过级别(如已到白银,下次直接考白银)。

四、必须遵守的竞赛规则与常见误区

允许的行为

使用纸质书籍、公开网络资源(如GeeksforGeeks、CP-Algorithms);

复用自己过去写过的代码;

使用标准库函数(如C++ STL、Java Collections)。

严禁的行为(视为作弊)

行为 后果
直接输出答案(如 print("42")) 成绩作废 + 可能禁赛
使用AI生成/调试代码(ChatGPT、Copilot等) 2026年起明确禁止,违者终身禁赛
未注释引用代码 即使是自己写的旧代码,也需加注释说明来源
与他人讨论题目或思路 必须独立完成,任何形式协作均违规

正确做法:

若使用外部代码模板,务必添加注释

备赛的同学可扫码免费领取新赛季USACO全套干货资料⇓

USACO一对一辅导规划!

在线咨询
联系客服