CF1490E.Accidental Victory

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A championship is held in Berland, in which nn players participate. The player with the number ii has aia_i (ai≥1a_i \ge 1) tokens.

The championship consists of n−1n-1 games, which are played according to the following rules:

  • in each game, two random players with non-zero tokens are selected;
  • the player with more tokens is considered the winner of the game (in case of a tie, the winner is chosen randomly);
  • the winning player takes all of the loser's tokens;

The last player with non-zero tokens is the winner of the championship.

All random decisions that are made during the championship are made equally probable and independently.

For example, if n=4n=4, a=[1,2,4,3]a = [1, 2, 4, 3], then one of the options for the game (there could be other options) is:

  • during the first game, the first and fourth players were selected. The fourth player has more tokens, so he takes the first player's tokens. Now a=[0,2,4,4]a = [0, 2, 4, 4];
  • during the second game, the fourth and third players were selected. They have the same number of tokens, but in a random way, the third player is the winner. Now a=[0,2,8,0]a = [0, 2, 8, 0];
  • during the third game, the second and third players were selected. The third player has more tokens, so he takes the second player's tokens. Now a=[0,0,10,0]a = [0, 0, 10, 0];
  • the third player is declared the winner of the championship.

Championship winners will receive personalized prizes. Therefore, the judges want to know in advance which players have a chance of winning, i.e have a non-zero probability of winning the championship. You have been asked to find all such players.

在贝尔兰举行了一场锦标赛,共有 nn 名选手参加。编号为 ii 的选手拥有 aia_i(ai≥1a_i \ge 1)个代币。

该锦标赛共进行 n−1n-1 场比赛,规则如下:

  • 每场比赛随机选取两名代币数非零的选手;
  • 代币数较多者获胜(若代币数相等,则随机决定胜者);
  • 获胜者获得失败者全部的代币;

最后一名代币数非零的选手即为锦标赛冠军。

锦标赛中所有随机决策均等概率且相互独立地进行。

例如,当 n=4n=4、a=[1,2,4,3]a = [1, 2, 4, 3] 时,一种可能的比赛过程(其他过程也可能发生)如下:

  • 第一场比赛选中了第 1 号和第 4 号选手。第 4 号选手代币更多,因此他获得第 1 号选手的所有代币。此时 a=[0,2,4,4]a = [0, 2, 4, 4];
  • 第二场比赛选中了第 4 号和第 3 号选手。两人代币数相同,但通过随机方式判定第 3 号选手获胜。此时 a=[0,2,8,0]a = [0, 2, 8, 0];
  • 第三场比赛选中了第 2 号和第 3 号选手。第 3 号选手代币更多,因此他获得第 2 号选手的所有代币。此时 a=[0,0,10,0]a = [0, 0, 10, 0];
  • 第 3 号选手被宣布为锦标赛冠军。

锦标赛冠军将获得个性化奖品。因此,裁判希望提前知道哪些选手有可能夺冠,即夺冠概率严格大于零。你需要找出所有这样的选手。

输入格式

The first line contains one integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases. Then tt test cases follow.

The first line of each test case consists of one positive integer nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) — the number of players in the championship.

The second line of each test case contains nn positive integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \le a_i \le 10^9) — the number of tokens the players have.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 测试用例的数量。接下来是 tt 个测试用例。

每个测试用例的第一行包含一个正整数 nn(1≤n≤2⋅1051 \le n \le 2 \cdot 10^5)—— 锦标赛中玩家的数量。

每个测试用例的第二行包含 nn 个正整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1091 \le a_i \le 10^9)—— 各玩家所拥有的代币数量。

保证所有测试用例的 nn 之和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, print the number of players who have a nonzero probability of winning the championship. On the next line print the numbers of these players in increasing order. Players are numbered starting from one in the order in which they appear in the input.

对于每个测试用例,输出有非零概率赢得冠军的选手人数。
下一行按升序输出这些选手的编号。选手编号从 1 开始,按照其在输入中出现的顺序依次编号。

输入输出样例

  • 输入#1

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

    输出#1

    3
    2 3 4 
    5
    1 2 3 4 5

输入解题思路,AI测评打分。不知道怎么写?

首页