CF1733B.Rule of League
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is a badminton championship in which n players take part. The players are numbered from 1 to n.
The championship proceeds as follows: player 1 and player 2 play a game, then the winner and player 3 play a game, and then the winner and player 4 play a game, and so on. So, n−1 games are played, and the winner of the last game becomes the champion. There are no draws in the games.
You want to find out the result of championship. Currently, you only know the following information:
- Each player has either won x games or y games in the championship.
Given n, x, and y, find out if there is a result that matches this information.
有一场羽毛球锦标赛,共有 n 名选手参加。选手编号从 1 到 n。
锦标赛按如下方式进行:选手 1 与选手 2 进行一场比赛;然后胜者与选手 3 进行一场比赛;接着该胜者再与选手 4 进行一场比赛;依此类推。因此共进行 n−1 场比赛,最后一场比赛的胜者成为冠军。所有比赛均无平局。
你想确定锦标赛的结果。目前你仅知道以下信息:
- 每名选手在锦标赛中恰好赢了 x 场或 y 场比赛。
给定 n、x 和 y,请判断是否存在一种符合该信息的比赛结果。
输入格式
The first line contains one integer t (1≤t≤105) — the number of test cases.
The only line of each test case contains three integers n, x, y (2≤n≤105, 0≤x,y<n).
It is guaranteed that the sum of n over all test cases doesn't exceed 2⋅105.
第一行包含一个整数 t(1≤t≤105)—— 测试用例的数量。
每个测试用例仅有一行,包含三个整数 n、x、y(2≤n≤105,0≤x,y<n)。
保证所有测试用例的 n 之和不超过 2⋅105。
输出格式
Print the answer for each test case, one per line. If there is no result that matches the given information about n, x, y, print −1. Otherwise, print n−1 space separated integers, where the i-th integer is the player number of the winner of the i-th game.
If there are multiple valid results, print any.
对每个测试用例,输出一行答案。如果不存在满足给定 n、x、y 条件的结果,则输出 −1;否则,输出 n−1 个以空格分隔的整数,其中第 i 个整数表示第 i 场比赛获胜者的玩家编号。
若存在多个合法结果,输出任意一个即可。
输入输出样例
输入#1
5 5 2 0 8 1 2 3 0 0 2 0 1 6 3 0
输出#1
1 1 4 4 -1 -1 2 -1
说明/提示
In the first test case, player 1 and player 4 won x times, player 2 and player 3 won y times.
In the second, third, and fifth test cases, no valid result exists.
在第一个测试用例中,玩家 1 和玩家 4 各获胜 x 次,玩家 2 和玩家 3 各获胜 y 次。
在第二、第三和第五个测试用例中,不存在合法的结果。
输入解题思路,AI测评打分。不知道怎么写?