CF1251A.Broken Keyboard

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Recently Polycarp noticed that some of the buttons of his keyboard are malfunctioning. For simplicity, we assume that Polycarp's keyboard contains 2626 buttons (one for each letter of the Latin alphabet). Each button is either working fine or malfunctioning.

To check which buttons need replacement, Polycarp pressed some buttons in sequence, and a string ss appeared on the screen. When Polycarp presses a button with character cc, one of the following events happened:

  • if the button was working correctly, a character cc appeared at the end of the string Polycarp was typing;
  • if the button was malfunctioning, two characters cc appeared at the end of the string.

For example, suppose the buttons corresponding to characters a and c are working correctly, and the button corresponding to b is malfunctioning. If Polycarp presses the buttons in the order a, b, a, c, a, b, a, then the string he is typing changes as follows: a →\rightarrow abb →\rightarrow abba →\rightarrow abbac →\rightarrow abbaca →\rightarrow abbacabb →\rightarrow abbacabba.

You are given a string ss which appeared on the screen after Polycarp pressed some buttons. Help Polycarp to determine which buttons are working correctly for sure (that is, this string could not appear on the screen if any of these buttons was malfunctioning).

You may assume that the buttons don't start malfunctioning when Polycarp types the string: each button either works correctly throughout the whole process, or malfunctions throughout the whole process.

最近,Polycarp 发现他键盘上的某些按键出现了故障。为简化问题,我们假设 Polycarp 的键盘包含 2626 个按键(每个拉丁字母对应一个按键)。每个按键要么工作正常,要么完全故障。

为了检查哪些按键需要更换,Polycarp 按照某种顺序按下了若干按键,屏幕上出现了一个字符串 ss。当 Polycarp 按下对应字符 cc 的按键时,会发生以下两种情况之一:

  • 若该按键工作正常,则字符 cc 会添加到 Polycarp 正在输入的字符串末尾;
  • 若该按键发生故障,则字符 cc 会连续两次添加到字符串末尾(即添加 cccc)。

例如,假设对应字符 a 和 c 的按键工作正常,而对应 b 的按键发生故障。若 Polycarp 按照 a, b, a, c, a, b, a 的顺序按下按键,则他正在输入的字符串变化过程如下:
a →\rightarrow abb →\rightarrow abba →\rightarrow abbac →\rightarrow abbaca →\rightarrow abbacabb →\rightarrow abbacabba。

现给定屏幕上最终出现的字符串 ss(即 Polycarp 按下一系列按键后得到的结果)。请帮助 Polycarp 确定哪些按键一定工作正常(即:若其中任一按键发生故障,则该字符串 ss 就不可能出现在屏幕上)。

你可以假设:在 Polycarp 输入整个字符串的过程中,各按键的状态保持不变——每个按键在整个过程中要么始终工作正常,要么始终发生故障。

输入格式

The first line contains one integer tt (1≤t≤1001 \le t \le 100) — the number of test cases in the input.

Then the test cases follow. Each test case is represented by one line containing a string ss consisting of no less than 11 and no more than 500500 lowercase Latin letters.

第一行包含一个整数 tt(1≤t≤1001 \le t \le 100)—— 表示输入中测试用例的数量。

接下来是各测试用例。每个测试用例由一行字符串 ss 表示,该字符串由至少 11 个、至多 500500 个小写拉丁字母组成。

输出格式

For each test case, print one line containing a string resres. The string resres should contain all characters which correspond to buttons that work correctly in alphabetical order, without any separators or repetitions. If all buttons may malfunction, resres should be empty.

对于每个测试用例,输出一行字符串 resres。字符串 resres 应包含所有功能正常的按键所对应的字符,并按字母顺序排列,中间不加任何分隔符,且不包含重复字符。如果所有按键都可能失灵,则 resres 应为空。

输入输出样例

  • 输入#1

    4
    a
    zzaaz
    ccff
    cbddbb

    输出#1

    a
    z
    
    bc

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

首页