CF1779H.Olympic Team Building

NOI/NOI+/CTSC

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Iron and Werewolf are participating in a chess Olympiad, so they want to practice team building. They gathered nn players, where nn is a power of 22, and they will play sports. Iron and Werewolf are among those nn people.

One of the sports is tug of war. For each 1≤i≤n1\leq i \leq n, the ii-th player has strength sis_i. Elimination rounds will be held until only one player remains — we call that player the absolute winner.

In each round:

  • Assume that m>1m \gt 1 players are still in the game, where mm is a power of 22.
  • The mm players are split into two teams of equal sizes (i. e., with m/2m/2 players in each team). The strength of a team is the sum of the strengths of its players.
  • If the teams have equal strengths, Iron chooses who wins; otherwise, the stronger team wins.
  • Every player in the losing team is eliminated, so m/2m/2 players remain.

Iron already knows each player's strength and is wondering who can become the absolute winner and who can't if he may choose how the teams will be formed in each round, as well as the winning team in case of equal strengths.

铁和狼人正在参加国际象棋奥林匹克竞赛,因此他们希望练习团队建设。他们召集了 nn 名选手,其中 nn 是 22 的幂,这些选手将进行一项体育活动。铁和狼人本人也在该 nn 名选手之中。

其中一项运动是拔河。对每个 1≤i≤n1 \leq i \leq n,第 ii 名选手的力量值为 sis_i。比赛将进行多轮淘汰赛,直至仅剩一名选手——我们称该选手为“绝对冠军”。

每一轮的规则如下:

  • 假设当前仍有 m>1m > 1 名选手留在比赛中,且 mm 是 22 的幂;
  • 这 mm 名选手被平均分为两支队伍(即每支队伍恰好有 m/2m/2 名选手)。一支队伍的总力量值等于其所有队员力量值之和;
  • 若两支队伍力量值相等,则由铁决定哪支队伍获胜;否则,力量值更大的队伍获胜;
  • 落败队伍中的所有选手均被淘汰,因此剩余 m/2m/2 名选手。

铁已知晓每位选手的力量值,并希望知道:在每轮均可自主决定队伍如何分组、且在力量值相等时也可自主决定胜方的前提下,哪些选手可能成为绝对冠军,哪些不可能。

输入格式

The first line contains a single integer nn (4≤n≤324 \leq n \leq 32) — the number of players participating in tug of war. It is guaranteed that nn is a power of 22.

The second line consists of a sequence s1,s2,…,sns_1,s_2, \ldots, s_n of integers (1≤si≤10151 \leq s_i \leq 10^{15}) — the strengths of the players.

第一行包含一个整数 nn(4≤n≤324 \leq n \leq 32)—— 参加拔河比赛的玩家人数。保证 nn 是 22 的幂。

第二行包含一个整数序列 s1,s2,…,sns_1,s_2, \ldots, s_n(1≤si≤10151 \leq s_i \leq 10^{15})—— 各玩家的力量值。

输出格式

In a single line output a binary string ss of length nn — the ii-th character of ss should be 11 if the ii-th player can become the absolute winner and it should be 00 otherwise.

在一行中输出一个长度为 nn 的二进制字符串 ss —— 若第 ii 位玩家能成为绝对冠军,则 ss 的第 ii 个字符应为 11,否则为 00。

输入输出样例

  • 输入#1

    4
    60 32 59 87

    输出#1

    1001
  • 输入#2

    4
    100 100 100 100

    输出#2

    1111
  • 输入#3

    8
    8 8 8 8 4 4 4 4

    输出#3

    11110000
  • 输入#4

    32
    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

    输出#4

    00000000000000001111111111111111
  • 输入#5

    16
    1 92875987325987 1 1 92875987325986 92875987325985 1 92875987325988 92875987325990 92875987325989 1 1 92875987325984 92875987325983 1 1

    输出#5

    0100110111001000

说明/提示

In the first example, players 11 and 44 with their respective strengths of 6060 and 8787 can become the absolute winners.

Let's describe the process for player 11. Firstly, we divide the players into teams [1,3][1,3] and [2,4][2,4]. Strengths of those two teams are 60+59=11960+59=119 and 32+87=11932+87=119. They they are equal, Iron can choose to disqualify any of the two teams. Let his choice be the second team.

We are left with players 11 and 33. Since 11 has greater strength (60>5960 \gt 59) they win and are declared the absolute winner as they are the last remaining player.

In the third example, the strengths of the remaining players may look like [8,8,8,8,4,4,4,4]→[8,8,4,4]→[8,4]→[8][8,8,8,8,4,4,4,4] \rightarrow [8,8,4,4] \rightarrow [8,4] \rightarrow [8]. Each person with strength 88 can become the absolute winner and it can be proved that others can't.

在第一个例子中,玩家 11 和 44(其对应实力分别为 6060 和 8787)可以成为绝对获胜者。

我们以玩家 11 为例描述该过程。首先,我们将所有玩家分为两支队伍:[1,3][1,3] 和 [2,4][2,4]。这两支队伍的实力分别为 60+59=11960+59=119 和 32+87=11932+87=119。由于两队实力相等,Iron 可以选择取消其中任意一支队伍的资格。假设他选择取消第二支队伍的资格。

此时剩余玩家为 11 和 33。由于玩家 11 的实力更大(60>5960 \gt 59),因此获胜,并作为最后剩下的玩家被宣布为绝对获胜者。

在第三个例子中,剩余玩家的实力序列可能如下变化:[8,8,8,8,4,4,4,4]→[8,8,4,4]→[8,4]→[8][8,8,8,8,4,4,4,4] \rightarrow [8,8,4,4] \rightarrow [8,4] \rightarrow [8]。每个实力为 88 的玩家均可成为绝对获胜者,且可以证明其余玩家无法做到这一点。

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

首页