CF1867C.Salyg1n and the MEX Game

普及-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

This is an interactive problem!

salyg1n gave Alice a set SS of nn distinct integers s1,s2,…,sns_1, s_2, \ldots, s_n (0≤si≤1090 \leq s_i \leq 10^9). Alice decided to play a game with this set against Bob. The rules of the game are as follows:

  • Players take turns, with Alice going first.

  • In one move, Alice adds one number xx (0≤x≤1090 \leq x \leq 10^9) to the set SS. The set SS must not contain the number xx at the time of the move.

  • In one move, Bob removes one number yy from the set SS. The set SS must contain the number yy at the time of the move. Additionally, the number yy must be strictly smaller than the last number added by Alice.

  • The game ends when Bob cannot make a move or after 2⋅n+12 \cdot n + 1 moves (in which case Alice's move will be the last one).

  • The result of the game is MEX⁡†(S)\operatorname{MEX}\dagger(S) (SS at the end of the game).

  • Alice aims to maximize the result, while Bob aims to minimize it.

Let RR be the result when both players play optimally. In this problem, you play as Alice against the jury program playing as Bob. Your task is to implement a strategy for Alice such that the result of the game is always at least RR.

†\dagger MEX⁡\operatorname{MEX} of a set of integers c1,c2,…,ckc_1, c_2, \ldots, c_k is defined as the smallest non-negative integer xx which does not occur in the set cc. For example, MEX⁡(0,1,2,4)\operatorname{MEX}({0, 1, 2, 4}) == 33.

这是一个交互式问题!

salyg1n 给了 Alice 一个包含 nn 个互不相同整数 s1,s2,…,sns_1, s_2, \ldots, s_n 的集合 SS(其中 0≤si≤1090 \leq s_i \leq 10^9)。Alice 决定用该集合与 Bob 进行一场博弈。游戏规则如下:

  • 双方轮流行动,Alice 先手。

  • 在一次行动中,Alice 向集合 SS 中添加一个数 xx(0≤x≤1090 \leq x \leq 10^9)。在行动时,集合 SS 中不能已含有该数 xx。

  • 在一次行动中,Bob 从集合 SS 中移除一个数 yy。在行动时,集合 SS 中必须已含有该数 yy;此外,该数 yy 必须严格小于 Alice 上一次所添加的数。

  • 当 Bob 无法行动,或总行动次数达到 2⋅n+12 \cdot n + 1 次时,游戏结束(此时 Alice 的行动为最后一次)。

  • 游戏的得分为 MEX⁡†(S)\operatorname{MEX}\dagger(S)(即游戏结束时集合 SS 的 MEX⁡\operatorname{MEX} 值)。

  • Alice 的目标是使得分尽可能大,而 Bob 的目标是使得分尽可能小。

设 RR 为双方均采取最优策略时的游戏结果。本题中,你将扮演 Alice,而评测程序将扮演 Bob。你的任务是实现一种 Alice 的策略,使得游戏结果始终至少为 RR。

†\dagger 一组整数 c1,c2,…,ckc_1, c_2, \ldots, c_k 的 MEX⁡\operatorname{MEX} 定义为未出现在该集合中的最小非负整数 xx。例如,MEX⁡(0,1,2,4)=3\operatorname{MEX}({0, 1, 2, 4}) = 3。

输入格式

The first line contains an integer tt (1≤t≤1051 \leq t \leq 10^5) - the number of test cases.

第一行包含一个整数 tt(1≤t≤1051 \leq t \leq 10^5)——测试用例的数量。

输入输出样例

  • 输入#1

    3
    5
    1 2 3 5 7
    
    7
    
    5
    
    -1
    
    3
    0 1 2
    
    0
    
    -1
    
    3
    5 7 57
    
    -1

    输出#1

    8
    
    57
    
    0
    
    3
    
    0
    
    0

说明/提示

In the first test case, the set SS changed as follows:

{1,2,3,5,71, 2, 3, 5, 7} →\to {1,2,3,5,7,81, 2, 3, 5, 7, 8} →\to {1,2,3,5,81, 2, 3, 5, 8} →\to {1,2,3,5,8,571, 2, 3, 5, 8, 57} →\to {1,2,3,8,571, 2, 3, 8, 57} →\to {0,1,2,3,8,570, 1, 2, 3, 8, 57}. In the end of the game, MEX⁡(S)=4\operatorname{MEX}(S) = 4, R=4R = 4.

In the second test case, the set SS changed as follows:

{0,1,20, 1, 2} →\to {0,1,2,30, 1, 2, 3} →\to {1,2,31, 2, 3} →\to {0,1,2,30, 1, 2, 3}. In the end of the game, MEX⁡(S)=4\operatorname{MEX}(S) = 4, R=4R = 4.

In the third test case, the set SS changed as follows:

{5,7,575, 7, 57} →\to {0,5,7,570, 5, 7, 57}. In the end of the game, MEX⁡(S)=1\operatorname{MEX}(S) = 1, R=1R = 1.

在第一个测试用例中,集合 SS 的变化过程如下:

{1,2,3,5,71, 2, 3, 5, 7} →\to {1,2,3,5,7,81, 2, 3, 5, 7, 8} →\to {1,2,3,5,81, 2, 3, 5, 8} →\to {1,2,3,5,8,571, 2, 3, 5, 8, 57} →\to {1,2,3,8,571, 2, 3, 8, 57} →\to {0,1,2,3,8,570, 1, 2, 3, 8, 57}。游戏结束时,MEX⁡(S)=4\operatorname{MEX}(S) = 4,R=4R = 4。

在第二个测试用例中,集合 SS 的变化过程如下:

{0,1,20, 1, 2} →\to {0,1,2,30, 1, 2, 3} →\to {1,2,31, 2, 3} →\to {0,1,2,30, 1, 2, 3}。游戏结束时,MEX⁡(S)=4\operatorname{MEX}(S) = 4,R=4R = 4。

在第三个测试用例中,集合 SS 的变化过程如下:

{5,7,575, 7, 57} →\to {0,5,7,570, 5, 7, 57}。游戏结束时,MEX⁡(S)=1\operatorname{MEX}(S) = 1,R=1R = 1。

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

首页