CF135C.Zero-One
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Little Petya very much likes playing with little Masha. Recently he has received a game called "Zero-One" as a gift from his mother. Petya immediately offered Masha to play the game with him.
Before the very beginning of the game several cards are lain out on a table in one line from the left to the right. Each card contains a digit: 0 or 1. Players move in turns and Masha moves first. During each move a player should remove a card from the table and shift all other cards so as to close the gap left by the removed card. For example, if before somebody's move the cards on the table formed a sequence 01010101, then after the fourth card is removed (the cards are numbered starting from 1), the sequence will look like that: 0100101.
The game ends when exactly two cards are left on the table. The digits on these cards determine the number in binary notation: the most significant bit is located to the left. Masha's aim is to minimize the number and Petya's aim is to maximize it.
An unpleasant accident occurred before the game started. The kids spilled juice on some of the cards and the digits on the cards got blurred. Each one of the spoiled cards could have either 0 or 1 written on it. Consider all possible variants of initial arrangement of the digits (before the juice spilling). For each variant, let's find which two cards are left by the end of the game, assuming that both Petya and Masha play optimally. An ordered pair of digits written on those two cards is called an outcome. Your task is to find the set of outcomes for all variants of initial digits arrangement.
小佩佳非常喜欢和小玛莎一起玩耍。最近,他从妈妈那里收到了一份名为“零一游戏”的礼物。佩佳立刻邀请玛莎和他一起玩这个游戏。
游戏开始前,若干张卡片从左至右排成一行放在桌上。每张卡片上印有一个数字:0 或 1。双方轮流行动,玛莎先手。每次行动中,玩家需从桌上移除一张卡片,并将其他所有卡片向空缺处平移以填补空隙。例如,若某人行动前桌上的卡片序列为 01010101,而该玩家移除了第 4 张卡片(卡片编号从 1 开始),则行动后序列变为:0100101。
当桌上恰好剩下两张卡片时,游戏结束。这两张卡片上的数字构成一个二进制数:左侧的数字为最高有效位(most significant bit)。玛莎的目标是使该二进制数尽可能小,而佩佳的目标是使其尽可能大。
游戏开始前发生了一件不愉快的意外:孩子们将果汁洒在部分卡片上,导致其上的数字变得模糊不清。每张被污染的卡片上原本可能是 0,也可能是 1。考虑所有可能的初始数字排列(即果汁泼洒前的所有可能情形)。对每一种初始排列,在双方均采取最优策略的前提下,确定游戏结束时所剩余的两张卡片。将这两张卡片上数字组成的有序对称为一个结果(outcome)。你的任务是求出所有初始数字排列对应的所有可能结果所构成的集合。
输入格式
The first line contains a sequence of characters each of which can either be a "0", a "1" or a "?". This sequence determines the initial arrangement of cards on the table from the left to the right. The characters "?" mean that the given card was spoiled before the game. The sequence's length ranges from 2 to 105, inclusive.
第一行包含一个字符序列,每个字符为 "0"、"1" 或 "?" 中的一个。该序列从左到右决定了桌面上卡片的初始排列。字符 "?" 表示对应位置的卡片在游戏开始前已被损坏。序列长度范围为 2 到 105(含端点)。
输出格式
Print the set of outcomes for all possible initial digits arrangements. Print each possible outcome on a single line. Each outcome should be represented by two characters: the digits written on the cards that were left by the end of the game. The outcomes should be sorted lexicographically in ascending order (see the first sample).
打印所有可能的初始数字排列所对应的结果集合。每个可能的结果单独占一行。每个结果由两个字符表示:游戏结束时剩余卡片上的数字。结果应按字典序升序排列(参见第一个样例)。
输入输出样例
输入#1
????
输出#1
00 01 10 11
输入#2
1010
输出#2
10
输入#3
1?1
输出#3
01 11
说明/提示
In the first sample all 16 variants of numbers arrangement are possible. For the variant 0000 the outcome is 00. For the variant 1111 the outcome is 11. For the variant 0011 the outcome is 01. For the variant 1100 the outcome is 10. Regardless of outcomes for all other variants the set which we are looking for will contain all 4 possible outcomes.
In the third sample only 2 variants of numbers arrangement are possible: 111 and 101. For the variant 111 the outcome is 11. For the variant 101 the outcome is 01, because on the first turn Masha can remove the first card from the left after which the game will end.
在第一个样例中,所有 16 种数字排列方式均是可能的。对于排列 0000,结果为 00;对于排列 1111,结果为 11;对于排列 0011,结果为 01;对于排列 1100,结果为 10。无论其余所有排列对应的结果如何,我们所求的集合都将包含全部 4 种可能的结果。
在第三个样例中,仅有 2 种数字排列方式是可能的:111 和 101。对于排列 111,结果为 11;对于排列 101,结果为 01,因为玛莎在第一轮可以移除最左侧的第一张卡片,从而使游戏结束。
输入解题思路,AI测评打分。不知道怎么写?