USACO与NOI竞赛全景对比:升学路径与备赛策略指南

近年来,中国学生参与USACO竞赛的比例呈现显著增长趋势,2024年参赛人数中中国学生占比已达37%。这项起源于美国的计算机奥赛与国内NOI竞赛共同构成了青少年编程领域的双峰,但两者在竞赛体系、知识结构及升学价值等方面存在显著差异。

一、竞赛体系深度解析

1.赛事背景与组织架构

USACO(美国计算机奥林匹克竞赛)由美国知名高校命题委员会直接运营,采用全年开放的月赛机制。其赛制允许选手不限次数挑战晋级,青铜至铂金四个等级构成阶梯式晋级路径,年度终选将产生美国国家队候选名单。

NOI(全国青少年信息学奥林匹克竞赛)由中国计算机学会主办,作为五大学科竞赛之一,采用省选-全国赛-国际赛的晋级模式。省级联赛(NOIP)每年11月举行,全国赛次年7月举办,最终选拔国家集训队成员。

2.知识体系差异对比

USACO侧重经典算法应用,约80%题目涉及动态规划、图论算法和搜索优化等模块化知识。

NOI则呈现更强的学科交叉性,除基础算法外,近年试题频繁出现组合数学、计算几何等拓展领域。特别值得注意的是,自2021年起,命题组开始融入机器学习特征提取等人工智能相关考点。

二、升学价值实证分析

1.海外留学申请维度

MIT、斯坦福等顶尖院校招生办公室在公开文件中明确提及USACO成绩的参考价值。但需要特别说明的是,NOI金牌得主在申请中同样具有竞争力。

2.国内升学通道比较

获得NOI铜牌的学生通过强基计划录取(如复旦要求NOI铜牌+高考达一本线)。而USACO成绩目前尚未进入国内高校官方认可体系,但部分重点中学的国际部在自主招生中会将其作为编程能力证明。

三、备赛策略与路径规划

1.学习周期适配建议

对于编程启蒙较晚(初中阶段)的学生,USACO的渐进式晋级体系更具包容性。其月赛机制允许学生在12个月内完成青铜到铂金的跃迁,典型案例显示有学生通过6次月赛实现等级跨越。

2.能力培养重点差异

USACO备赛需强化标准化解题能力,建议建立包含200+核心算法的代码模板库。例如图论模块需要准备DFS、BFS、Dijkstra等8种基础算法的优化版本。

NOI备赛则需拓展跨学科思维,近年试题中出现的量子计算初步和生物信息学相关题目,要求选手具备快速学习新兴领域知识的能力。

四、课程选择决策模型

1.师资配置评估要点

我们USACO课程具备算法竞赛金牌师资,建议优先选择授课教师具有IOI/USACO铂金执教经历的机构。部分头部机构已形成清华、浙大等计算机强校毕业生的稳定师资梯队。

2.教学体系构建标准

科学的教学周期应包含三个阶段:基础阶段完成数据结构与基础算法搭建,强化阶段着重高频考点突破,冲刺阶段进行全真模拟训练。

五、竞赛选择决策树

升学目标优先型

海外留学:USACO铂金级+NOIP普及组一等奖

国内升学:NOI铜牌+USACO黄金级

能力发展导向型

算法实践能力:USACO月赛持续挑战

创新能力培养:NOI系列赛事进阶

时间管理适配型

碎片化时间:USACO在线月赛机制

集中特训:NOI省级夏令营体系

【扫码免费领取】USACO真题&高效算法书+USACO一对一辅导规划!

通往世界顶尖计算机名校的阶梯​​!USACO竞赛不同等级能申请什么样的大学?

USACO(美国计算机奥林匹克竞赛)作为全球计算机领域最具影响力的赛事之一,其竞赛成绩已成为众多顶尖高校计算机专业申请中的重要参考。无论是青铜级的基础能力证明,还是铂金级的顶尖水平认证,不同级别的奖项都能为申请者带来差异化优势。

一、USACO竞赛级别与核心考点解析​​

青铜级(Bronze):算法思维的入门基石​​

青铜级面向编程初学者,重点考察基础编程能力和简单算法实现。参赛者需熟练掌握至少一门编程语言(如Python、Java或C++)的语法结构,包括变量定义、循环控制、条件分支和函数封装。

在算法层面,需具备将实际问题转化为代码的能力,例如通过枚举法解决简单查找问题。常见考点包括一维数组操作、基本字符串处理以及时间复杂度为O(n²)的暴力解法。

通过青铜级认证,意味着申请者已具备初步的计算机逻辑思维,这对申请美国Top 50大学理工科专业具有基础性背书作用。

白银级(Silver):数据结构与算法进阶​​

晋级白银级需掌握线性数据结构(如队列、栈)的实际应用,并能够灵活运用递归、二分查找等经典算法。典型题目包括利用深度优先搜索(DFS)处理路径查找问题,或通过贪心算法优化资源分配方案。

此阶段要求学生不仅能写出正确代码,还需分析不同解法的效率差异。

白银级证书可显著提升申请美国Top 30院校(如加州大学圣地亚哥分校、伊利诺伊大学香槟分校)计算机相关专业的竞争力,证明申请者已超越基础编程水平。

黄金级(Gold):高阶算法与数学建模能力​​

黄金级标志着参赛者进入算法竞赛的核心领域。需要熟练运用动态规划解决背包问题、掌握图论中的最短路径算法(Dijkstra、Floyd-Warshall),并理解树状结构(如二叉树、红黑树)的实现原理。此阶段题目往往涉及组合数学与数论知识的综合应用,例如通过模运算优化大数处理。

黄金级获奖者在申请卡内基梅隆大学、康奈尔大学等Top 20院校时,其证书可作为算法能力的有力证明,部分学校甚至会给予学分抵免或优先科研项目参与资格。

铂金级(Platinum):顶尖人才的试金石​​

铂金级题目涉及后缀自动机、网络流算法等研究生阶段知识点,要求参赛者在4小时内完成多个高难度优化问题。典型挑战包括设计时间复杂度低于O(n log n)的线段树结构,或运用线性规划解决资源调度问题。

近三年数据显示,全球仅0.3%的参赛者能晋级铂金组,其获奖者多被MIT、斯坦福等超一流院校重点关注。

二、竞赛成绩与名校申请的对应关系​​

从近年录取案例看,不同级别奖项对应差异化申请策略:

青铜级:可增强佐治亚理工学院、普渡大学等理工强校的申请材料说服力

白银级:成为密歇根大学安娜堡分校、威斯康星大学麦迪逊分校等院校的优质辅助材料

黄金级:助力冲击加州大学伯克利分校、华盛顿大学西雅图等顶尖计算机院系

铂金级:常作为MIT、斯坦福、卡内基梅隆大学计算机专业的"敲门砖"

三、系统化备赛路径建议​​

阶段化学习规划:建议从青铜级考点开始夯实基础,用2-3个月完成语法与基础算法训练,再逐步过渡到白银级的递归与数据结构应用。黄金级备考通常需要6-8个月的高强度训练,建议每周投入至少15小时进行专题突破。

权威资源利用:推荐结合《算法导论》进行拓展学习,重点精读动态规划与图论章节。

竞赛技巧提升:在铂金级冲刺阶段,需注重代码调试效率。

扫码咨询usaco学术活动辅导课程+免费领取历年真题&参考书

2024-25赛季USACO竞赛难度分析!从青铜到铂金的晋级策略与备赛指南

近年来,USACO竞赛难度梯度发生显著变化,青铜组首次出现动态规划变种题,白银级通过率较往年下降30%,铂金级题目已对标中国NOI省选难度。

一、竞赛难度全面升级

(一)低级别组别筛选机制强化

青铜组难度突破传统框架:

2024年1月赛题首次出现动态规划变种题(原黄金级考点),典型如第三题涉及状态压缩与递推优化

白银组命题趋势显著变化:

图论题型占比提升至50%,其中二分图匹配与拓扑排序成为新重点

隐式证明要求强化,2024年1月白银P2需完成贪心策略数学证明

边界条件复杂度提升

(二)高级别组别学术门槛提升

黄金组出现IOI初级考点下沉现象,2024年3月赛题包含交互式编程与概率算法
铂金组难度重构特征:

代码规范评分权重提升至25%

动态难度调控机制启动,当某级别通过率超25%时下季必现"灭绝型"题目

二、2025-2026赛季安排解析(参考2024-25赛季)

(一)关键时间节点

第一场月赛:12月

第二场月赛:次年1月

第三场月赛:次年2月

美国公开赛:次年3月

(二)认证体系改革要点

金/铂金级实施定点考试制(美东时间12:00准时开考)

集训队选拔需3次认证成绩(含至少1次公开赛成绩)

AI辅助工具检测升级,代码相似度检测引入动态指纹技术

三、分阶备赛策略

(一)青铜→白银(建议6-8个月)

核心能力构建:

基础语法巩固:循环嵌套优化、多维数组应用

算法思维培养:暴力搜索优化(剪枝策略)、递推与简单贪心

重点突破方向:

全排列与子集生成算法(回溯模板)

前缀和与差分应用(二维场景)

简单图论实现(邻接矩阵存储)

(二)白银→黄金(建议8-12个月)

能力提升关键点:

动态规划体系构建(背包问题→状态压缩)

图论算法深化(Dijkstra→SPFA优化)

数据结构进阶(堆实现优先队列)

典型训练模式:

每周完成3道USACO银题+1道Codeforces 1600分题

重点攻克方向:

区间DP与树形DP

网络流基础建模

并查集路径压缩

(三)黄金→铂金(建议12-18个月)

核心能力要求:

组合数学应用(容斥原理、生成函数)

高级图论(强连通分量、2-SAT)

计算几何基础(凸包算法)

备赛要点:

每周进行IOI赛制模拟(5小时3题)

建立错题知识图谱(标注12类算法标签)

参与Codeforces 2000+级别竞赛

四、系统化训练方案

(一)基础能力建设

编程语言选择建议:

Python(青铜-白银)→C++(黄金-铂金)

代码规范训练标准:

变量命名规范(匈牙利/驼峰式)

模块化编程(函数封装度≥60%)

异常处理机制(边界检测覆盖率)

(二)算法能力进阶路径

青铜级重点:

模拟算法(复杂条件实现)

二分查找(最大值最小化)

简单数论(质数筛法)

黄金级核心:

线段树(区间修改查询)

树形DP(二次扫描法)

网络流(Dinic算法)

(三)竞赛技巧提升

时间管理策略:

题目分级处理(20分钟/题初步评估)

调试时间控制(不超过总时长25%)

代码优化技巧:

空间换时间策略(预处理机制)

输入输出加速(C++ios优化)

扫码咨询usaco学术活动辅导课程+免费领取历年真题&参考书

USACO竞赛新赛季比赛什么时候开始?USACO竞赛难度评析!

参加USACO竞赛能够为申请顶尖学府特别是理工科院校提供重要的加分项。许多知名大学,尤其是那些对于计算机编程能力要求较高的理工院校,对USACO竞赛的成绩极为重视。USACO竞赛比赛什么时候开始?

USACO竞赛规则介绍

适合学生:任意年级高中生(有编程基础的中小学生也可以参赛)

比赛形式:线上,个人赛,报名费用免费

比赛时间(参考2024-25赛季):

12月:第一场比赛

次年1月:第二场比赛

次年2月:第三场比赛

次年3月:美国公开赛

次年8-9月:训练营

考试费用:免费

考试形式:在线编码提交,每次比赛持续时间为4-5个小时,选手可以在规定的比赛窗口期内(例如周五至周一)自行选择开始比赛的时间。比赛期间,选手需要解决三道编程题目,题目难度随着组别的升高而增加,一旦选手登录并下载题目,计时器开始计时,要求选手在规定时间内编写代码并在网上提交。

评分标准:青铜、白银、黄金、铂金级别比赛都是3道题,总分1000分。每道题333.3分。每道题有10个测试点,通过一个可得33.33分。

USACO竞赛的难度评析

USACO竞赛的难度确实与国内NOIP竞赛相当,但命题水平较高。以下是关于USACO竞赛各等级难度的详细分析:

铜升银等级:

这一级别的难度相对较小,适合编程竞赛零基础的学生参加。只要学生学过编程语言以及编程常识,即使没有基础,晋级银级的难度也不大。在这个阶段,学生可以选择多种编程语言,如C/C++、Python、Java、Pascal等。对于新手来说,推荐使用C++或Python。

银升金等级:

这一级别的难度适中,要求学生掌握基础数据结构和算法。对于零基础的学生来说,需要系统复习相关知识。在这个阶段,学生将学习到更高级的数据结构和算法,为晋级铂金级别打下基础。

金升铂金等级:

这是USACO竞赛中最具挑战性的级别。在这一阶段,学生不仅需要熟练掌握编程语言,还需要深入掌握数据结构和算法。此外,灵活的算法思维对于晋级铂金级别至关重要。由于答题时间有限,学生需要在短时间内找到更优的解算法,才能在比赛中取得高分。

扫码咨询usaco学术活动辅导课程+免费领取历年真题&参考书

2025年USACO公开赛铜奖组问题三— It's Mooin' Time III

Elsie is trying to describe her favorite USACO contest to Bessie, but Bessie is having trouble understanding why Elsie likes it so much. Elsie says "And It's mooin' time! Who wants a mooin'? Please, I just want to do USACO".

Bessie still doesn't understand, so she transcribes Elsie's description in a string of length N (3≤N≤105 ) containing lowercase alphabetic characters s1s2…sN. Elsie considers a string t containing three characters a moo if t2=t3 and t2≠t1.

A triplet (i,j,k) is valid if i<j<k and string sisjsk forms a moo. For the triplet, FJ performs the following to calculate its value:

FJ bends string s 90-degrees at index j
The value of the triplet is twice the area of Δijk.

In other words, the value of the triplet is (ji)(kj).

Bessie asks you Q(1≤Q≤3⋅104) queries. In each query, she gives you two integers l and r (1≤lrN, rl+1≥3) and ask you for the maximum value among valid triplets (i,j,k) such that li and kr. If no valid triplet exists, output −1.

Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).

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

The first line contains two integers N and Q.

The following line contains s1s2,…sN.

The following Q lines contain two integers l and r, denoting each query.

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

Output the answer for each query on a new line.

SAMPLE INPUT:

12 5
abcabbacabac
1 12
2 7
4 8
2 5
3 10

SAMPLE OUTPUT:

28
6
1
-1
12

For the first query, (i,j,k) must satisfy 1≤i<j<k≤12. It can be shown that the maximum area of Δijk for some valid (i,j,k) is achieved when i=1, j=8, and k=12. Note that s1s8s12 is the string "acc" which is a moo according to the definitions above. Δijk will have legs of lengths 7 and 4 so two times the area of it will be 28.

For the third query, (i,j,k) must satisfy 4≤i<j<k≤8. It can be shown that the maximum area of Δijk for some valid (i,j,k) is achieved when i=4, j=5, and k=6.

For the fourth query, there exists no (i,j,k) satisfying 2≤i<j<k≤5 in which sisjsk is a moo so the output to that query is −1.

SCORING:

Inputs 2-3: N,Q≤50
Inputs 4-6: Q=1 and the singular query satisfies l=1 and r=N
Inputs 7-11: No additional constraints

Problem credits: Chongtian Ma

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

咨询一对一备赛规划

2025年USACO公开赛铜奖组问题二— More Cow Photos

The cows are in a particularly mischievous mood today! All Farmer John wants to do is take a photograph of the cows standing in a line, but they keep moving right before he has a chance to snap the picture.

Specifically, each of FJ's N cows (1≤N≤105) has an integer height from 1 to N. FJ wants to take a picture of the cows standing in line in a very specific ordering. If the cows have heights h1,…,hK when lined up from left to right, he wants the cow heights to have the following three properties:

He wants the cow heights to increase and then decrease. Formally, there must exist an integer i such that h1≤⋯≤hi≥⋯≥hK.

He does not want any cow standing next to another cow with exactly the same height. Formally, hihi+1 for all 1≤i<K.

He wants the picture to be symmetric. Formally, if i+j=K+1, then hi= hj.

FJ wants the picture to contain as many cows as possible. Specifically, FJ can remove some cows and rearrange the remaining ones. Compute the maximum number of cows FJ can have in the picture satisfying his constraints.

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

You have to answer multiple test cases.

The first line of input contains a single integer T (1≤T≤105) denoting the number of test cases. T test cases follow.

The first line of every test case contains a single integer N. The second line of every test case contains N integers, the heights of the N cows available. The cow heights will be between 1 and N.

It is guaranteed the sum of N over all test cases will not exceed 106.

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

Output T lines, the i'th line containing the answer to the i'th test case. Each line should be an integer denoting the maximum number of cows FJ can include in the picture.

SAMPLE INPUT:

2
4
1 1 2 3
4
3 3 2 1

SAMPLE OUTPUT:

3
1

For the first test case, FJ can take the cows with heights 1, 1, and 3, and rearrange them into [1,3,1], which satisfies all the conditions. For the second test case, FJ can take the cow with height 3and form a valid photo.

SCORING:

Inputs 2-3: T≤100,N≤7
Inputs 4-5: T≤104, all cows will have height at most 10.
Inputs 6-11: No additional constraints.

Problem credits: Nick Wu

2025年USACO公开赛铜奖组问题一— Hoof Paper Scissors Minus One

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

In a game of Hoof Paper Scissors, Bessie and Elsie can put out one of N (1≤N≤3000) different hoof symbols labeled 1…N, each corresponding to a different material. There is a complicated chart of how the different materials interact with one another, and based on that chart, either:

One symbol wins and the other loses.
The symbols draw against each other.

Hoof Paper Scissors Minus One works similarly, except Bessie and Elsie can each put out two symbols, one with each hoof. After observing all four symbols that they have all put out, they each choose one of their two symbols to play. The outcome is decided based on normal Hoof Paper Scissor conventions.

Given the M(1≤M≤3000) symbol combinations that Elsie plans to make across each game, Bessie wants to know how many different symbol combinations would result in a guaranteed win against Elsie. A symbol combination is defined as an ordered pair (L,R) where L is the symbol the cow plays with her left hoof and R is the symbol the cow plays with her right hoof. Can you compute this for each game?

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

The first line contains two space-separated integers N and M representing the number of hoof symbols and the number of games that Bessie and Elsie play.

Out of the following N lines of input, the ith line consists of i characters ai,1ai,2…ai,i where each ai,j∈{D,W,L}. If ai,j=D, then symbol i draws against symbol j. If ai,j=W, then symbol i wins against symbol j. If ai,j=L, then symbol i loses against symbol j. It is guaranteed that ai,i=D.

The next M lines contain two space separated integers s1 and s2 where 1≤s1,s2N. This represents Elsie's symbol combination for that game.

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

Output M lines where the i-th line contains the number of symbol combinations guaranteeing that Bessie can beat Elsie in the i-th game.

SAMPLE INPUT:

3 3
D
WD
LWD
1 2
2 3
1 1

SAMPLE OUTPUT:

0
0
5

In this example, this corresponds to the original Hoof Paper Scissors and we can let Hoof=1, Paper=2, and Scissors=3. Paper beats Hoof, Hoof beats Scissors, and Scissors beats Paper. There is no way for Bessie to guarantee a win against the combinations of Hoof+Paper or Paper+Scissors. However, if Elsie plays Hoof+Hoof, Bessie can counteract with any of the following combinations.

Paper+Paper
Paper+Scissors
Paper+Hoof
Hoof+Paper
Scissors+Paper

If Bessie plays any of these combinations, she can guarantee that she wins by putting forward Paper.

SCORING:

Inputs 2-6: N,M≤100
Inputs 7-12: No additional constraints.
Problem credits: Suhas Nagar

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

咨询一对一备赛规划

2025年USACO公开赛银奖组问题三—Ski Slope

Bessie is going on a ski trip with her friends. The mountain has N
waypoints (1≤N≤105) labeled 1,2,…,N in increasing order of altitude (waypoint 1
is the bottom of the mountain).

For each waypoint i>1, there is a ski run starting from waypoint i and ending at waypoint pi (1≤pi <i). This run has difficulty di(0≤di≤109 ) and enjoyment ei (0≤ei ≤109 ).

Each of Bessie's M friends (1≤M≤105) will do the following: They will pick some initial waypoint i to start at, and then follow the runs downward (to pi , then to  ppi, and so forth) until they get to waypoint 1.

The enjoyment each friend gets is equal to the sum of the enjoyments of the runs they follow. Each friend also has a different skill level sj (0≤sj≤109 ) and courage level cj (0≤cj≤10), which limits them to selecting an initial waypoint that results in them taking at most cj runs with difficulty greater than sj.

For each friend, compute the maximum enjoyment they can get.

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

The first line contains N.

Then for each i from 2 to N, a line follows containing three space-separated integers pi, di, and ei.

The next line contains M.

The next M lines each contain two space-separated integers sj and cj.

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

Output M lines, with the answer for each friend on a separate line.

Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).

SAMPLE INPUT:

4
1 20 200
2 30 300
2 10 100
8
19 0
19 1
19 2
20 0
20 1
20 2
29 0
30 0

SAMPLE OUTPUT:

0
300
500
300
500
500
300
500

1.The first friend cannot start any waypoint other than 1, since any other waypoint would cause them to take at least one run with difficulty greater than 19. Their total enjoyment is 0.
2.The second friend can start at waypoint 4 and take runs down to waypoint 2 and then 1. Their total enjoyment is 100+200=300. They take one run with difficulty greater than 19.
3.The third friend can start at waypoint 3 and take runs down to waypoint 2
and then 1. Their total enjoyment is 300+200=500. They take two runs with difficulty greater than 19.

SCORING:

Inputs 2-4: N,M≤1000
Inputs 5-7: All cj=0
Inputs 8-17: No additional constraints.

Problem credits: Brandon Wang

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

咨询一对一备赛规划

2025年USACO公开赛银奖组问题二—Compatible Pairs

Deep in the countryside, Farmer John’s cows aren’t just ordinary farm animals—they are part of a clandestine bovine intelligence network. Each cow carries an ID number, carefully assigned by the elite cow cryptographers. However, due to Farmer John's rather haphazard tagging system, some cows ended up with the same ID.

Farmer John noted that there are N(1≤N≤2⋅105) unique ID numbers, and for each unique ID di (0≤di≤109), there are ni(1≤ni≤109) cows who shared it.

The cows can only communicate in pairs, and their secret encryption method has one strict rule: two cows can only exchange information if they are not the same cow and the sum of their ID numbers equals either A or B(0≤A≤B≤2⋅109). A cow can only engage in one conversation at a time (i.e., no cow can be part of more than one pair).

Farmer John would like to maximize the number of disjoint communication pairs to ensure the best information flow. Can you determine the largest number of conversations that can happen at once?

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

The first line contains N, A, B.

The next N lines each contain ni and di. No two di are the same.

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

The maximum number of disjoint communicating pairs that can be formed at the same time.

Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).

SAMPLE INPUT:

4 4 5
17 2
100 0
10 1
200 4

SAMPLE OUTPUT:

118

A cow with an ID of 0 can communicate with another cow with an ID of 4 because the sum of their IDs is 4. Since there are a total of 100 cows of ID 0
and 200 cows of ID 4, there can be up to 100 communicating pairs with this combination of IDs.

A cow with an ID of 4 can also communicate with another cow with an ID of 1
(sum to 5). There are 10 cows of ID 1 and 100 remaining unpaired cows of ID 4
, allowing for another 10 pairs.

Finally, a cow with an ID of 2 can communicate with another cow of the same ID. Since there are a total of 17 cows of ID 2, there can be up to 8 more pairs.

In total, there are 100+10+8=118 communicating pairs. It can be shown that this is the maximum possible number of pairs.

SAMPLE INPUT:

4 4 5
100 0
10 1
100 3
20 4

SAMPLE OUTPUT:

30

Pairing IDs 0 and 4 makes 20 pairs, while pairing IDs 1 and 3 makes 10 pairs. It can be shown that this is the optimal pairing, resulting in a total of 30
pairs.

SCORING:

Inputs 3-4: A=B
Inputs 5-7: N≤1000
Inputs 8-12: No additional constraints

Problem credits: Benjamin Qi

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

咨询一对一备赛规划

2025年USACO公开赛银奖组问题一—Sequence Construction

Lately, the cows on Farmer John's farm have been infatuated with watching the show Apothecowry Dairies. The show revolves around a clever bovine sleuth CowCow solving problems of various kinds. Bessie found a new problem from the show, but the solution won't be revealed until the next episode in a week! Please solve the problem for her.

You are given integers M and K (1≤M≤109,1≤K≤31). Please choose a positive integer N and construct a sequence a of N non-negative integers such that the following conditions are satisfied:

1≤N≤100
a1+a2+⋯+aN=M
popcount(a1)⊕ popcount(a2)⊕⋯⊕ popcount(aN)=K
If no such sequence exists, print −1.

† popcount(x) is the number of bits equal to 1 in the binary representation of the integer x. For instance, the popcount of 11 is 3 and the popcount of 16 is 1.

†⊕is the bitwise xor operator.

The input will consist of T (1≤T≤5⋅103) independent test cases.

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

The first line contains T.

The first and only line of each test case has M and K.

It is guaranteed that all test cases are unique.

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

Output the solutions for T test cases as follows:

If no answer exists, the only line for that test case should be −1.

Otherwise, the first line for that test case should be a single integer N, the length of the sequence -- (1≤N≤100).

The second line for that test case should contain N space-separated integers that satisfy the conditions -- (0≤aiM).

SAMPLE INPUT:

3
2 1
33 5
10 5

SAMPLE OUTPUT:

2
2 0
3
3 23 7
-1

In the first test case, the elements in the array a=[2,0] sum to 2. The xor sum of popcounts is 1⊕0=1. Thus, all the conditions are satisfied.

In the second test case, the elements in the array a=[3,23,7] sum to 33. The xor sum of the popcounts is 2⊕4⊕3=5. Thus, all conditions are satisfied.

Other valid arrays are a=[4,2,15,5,7] and a=[1,4,0,27,1].

It can be shown that no valid arrays exist for the third test case.

SCORING:

Input 2: M≤8,K≤8
Inputs 3-5: M>2K
Inputs 6-18: No additional constraints.

Problem credits: Aakash Gokhale

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

咨询一对一备赛规划