链接:

https://codeforces.com/contest/1251/problem/A

题意:

Recently Polycarp noticed that some of the buttons of his keyboard are malfunctioning. For simplicity, we assume that Polycarp's keyboard contains 26 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 s appeared on the screen. When Polycarp presses a button with character c, one of the following events happened:

if the button was working correctly, a character c appeared at the end of the string Polycarp was typing;

if the button was malfunctioning, two characters c 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 → abb → abba → abbac → abbaca → abbacabb → abbacabba.

You are given a string s 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.

思路:

枚举长度, 只要有连续奇数字符,就满足条件。

代码:

#include<bits/stdc++.h>
using namespace std; int main()
{
ios::sync_with_stdio(false);
string s;
int t;
cin >> t;
while(t--)
{
cin >> s;
set<char> res;
for (int i = 0, j;i < (int)s.length();i=j+1)
{
j = i;
for (;j < (int)s.length();j++)
{
if (s[j] != s[i])
{
j--;
break;
}
}
j = min((int)s.length()-1, j);
if ((j-i+1)%2)
res.insert(s[i]);
}
for (auto v: res)
cout << v;
cout << endl;
} return 0;
}

Educational Codeforces Round 75 (Rated for Div. 2) A. Broken Keyboard的更多相关文章

  1. Educational Codeforces Round 75 (Rated for Div. 2)

    知识普及: Educational使用拓展ACM赛制,没有现场hack,比赛后有12h的全网hack时间. rank按通过题数排名,若通过题数相等则按罚时排名. (罚时计算方式:第一次通过每题的时间之 ...

  2. Educational Codeforces Round 75 (Rated for Div. 2) D. Salary Changing

    链接: https://codeforces.com/contest/1251/problem/D 题意: You are the head of a large enterprise. n peop ...

  3. Educational Codeforces Round 75 (Rated for Div. 2) C. Minimize The Integer

    链接: https://codeforces.com/contest/1251/problem/C 题意: You are given a huge integer a consisting of n ...

  4. Educational Codeforces Round 75 (Rated for Div. 2) B. Binary Palindromes

    链接: https://codeforces.com/contest/1251/problem/B 题意: A palindrome is a string t which reads the sam ...

  5. Educational Codeforces Round 75 (Rated for Div. 2)D(二分)

    #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;pair<int,int>a[20 ...

  6. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

  7. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

  8. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

  9. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

随机推荐

  1. [转帖]Red Hat K8s 关键人物 Grant Shipley 跳槽到 VMware

    Red Hat K8s 关键人物 Grant Shipley 跳槽到 VMware   https://news.cnblogs.com/n/641944/ 这四小时的工作效率 太无敌了.. 投递人  ...

  2. mysql 子句、子查询、连接查询

    一.mysql查询的五种子句 where子句(条件查询):按照“条件表达式”指定的条件进行查询. group by子句(分组):按照“属性名”指定的字段进行分组.group by子句通常和count( ...

  3. windowsAPI创建句柄失败的返回值

    创建句柄的api返回值 INVALID_HANDLE_VALUE CreateFile CreateNamedPipe CreateToolhelp32Snapshot FilterConnectCo ...

  4. 用 Scoop 管理你的 Windows 软件

    包管理系统,Homebrew 就是 macOS 上体验最佳的软件包管理,能帮助我们方便快捷.干净利落的管理软件.在Windows平台上也有一个非常棒的包管理软件--Scoop.Scoop 最适合安装那 ...

  5. .net core 杂记:用Autofac替换内置容器

    官方建议使用内置容器,但有些功能并不支持,如下: 属性注入 基于名称的注入 子容器 自定义生存期管理 Func<T> 支持 所以可以使用其他第三方IOC容器,如Autofac,下面为学习使 ...

  6. 转载:centos安装gitlab详解

    原文地址:http://blog.csdn.net/jiangtao_st/article/details/73612298 一, 服务器快速搭建gitlab方法 可以参考gitlab中文社区 的教程 ...

  7. cmd修改路径

    1.  切换盘符:    输入X:(例如C:)+回车 2.  查看当前目录下的文件:输入dir+回车 3.  选择想要的文件,输入:cd+文件名

  8. S5PV210 timer

    TCFG0, R/W, Address = 0xE250_0000 Timer Input Clock Frequency = PCLK / ( {prescaler value + 1} ) / { ...

  9. bootstrap tab选项卡

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  10. html流程实现

    https://blog.csdn.net/github_39335046/article/details/73930886 https://www.cnblogs.com/xcj26/p/98707 ...