CF1608C.Game Master

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

nn players are playing a game.

There are two different maps in the game. For each player, we know his strength on each map. When two players fight on a specific map, the player with higher strength on that map always wins. No two players have the same strength on the same map.

You are the game master and want to organize a tournament. There will be a total of n−1n-1 battles. While there is more than one player in the tournament, choose any map and any two remaining players to fight on it. The player who loses will be eliminated from the tournament.

In the end, exactly one player will remain, and he is declared the winner of the tournament. For each player determine if he can win the tournament.

有 nn 名玩家正在参与一场游戏。

游戏中有两张不同的地图。对于每名玩家,我们知道他在每张地图上的实力值。当两名玩家在某张特定地图上对战时,该地图上实力值更高的玩家总是获胜。任意两名玩家在同张地图上的实力值均不相同。

你作为游戏主持人,希望组织一场锦标赛。锦标赛总共将进行 n−1n-1 场对战。只要锦标赛中剩余的玩家数量多于一人,你就可以任选一张地图以及任意两名尚未被淘汰的玩家,让他们在该地图上对战;失败者将立即被淘汰。

最终,恰好会剩一名玩家,他即被宣布为锦标赛的冠军。请对每名玩家判断:他是否有可能赢得这场锦标赛。

输入格式

The first line contains a single integer tt (1≤t≤1001 \le t \le 100) — the number of test cases. The description of test cases follows.

The first line of each test case contains a single integer nn (1≤n≤1051 \leq n \leq 10^5) — the number of players.

The second line of each test case contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤1091 \leq a_i \leq 10^9, ai≠aja_i \neq a_j for i≠ji \neq j), where aia_i is the strength of the ii-th player on the first map.

The third line of each test case contains nn integers b1,b2,…,bnb_1, b_2, \dots, b_n (1≤bi≤1091 \leq b_i \leq 10^9, bi≠bjb_i \neq b_j for i≠ji \neq j), where bib_i is the strength of the ii-th player on the second map.

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5.

第一行包含一个整数 tt(1≤t≤1001 \le t \le 100)—— 表示测试用例的数量。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤1051 \leq n \leq 10^5)—— 表示玩家数量。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤1091 \leq a_i \leq 10^9,且当 i≠ji \neq j 时 ai≠aja_i \neq a_j),其中 aia_i 表示第 ii 位玩家在第一张地图上的实力。

每个测试用例的第三行包含 nn 个整数 b1,b2,…,bnb_1, b_2, \dots, b_n(1≤bi≤1091 \leq b_i \leq 10^9,且当 i≠ji \neq j 时 bi≠bjb_i \neq b_j),其中 bib_i 表示第 ii 位玩家在第二张地图上的实力。

保证所有测试用例中 nn 的总和不超过 10510^5。

输出格式

For each test case print a string of length nn. ii-th character should be "1" if the ii-th player can win the tournament, or "0" otherwise.

对于每个测试用例,输出一个长度为 nn 的字符串。其中第 ii 个字符应为 "1",如果第 ii 个选手能够赢得锦标赛;否则为 "0"。

输入输出样例

  • 输入#1

    3
    4
    1 2 3 4
    1 2 3 4
    4
    11 12 20 21
    44 22 11 30
    1
    1000000000
    1000000000

    输出#1

    0001
    1111
    1

说明/提示

In the first test case, the 44-th player will beat any other player on any game, so he will definitely win the tournament.

In the second test case, everyone can be a winner.

In the third test case, there is only one player. Clearly, he will win the tournament.

在第一个测试用例中,第 44 位玩家将在任意一局比赛中击败其他所有玩家,因此他必定赢得锦标赛。

在第二个测试用例中,任何玩家都有可能成为冠军。

在第三个测试用例中,仅有一位玩家。显然,他将赢得锦标赛。

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

首页