链接:

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. hexo 个人博客搭建

    Hexo 小插曲介绍 虽然标题是第一次写博客. 但是我这个困难户至少挣扎了1年多了, 一直下不去手.今天可算是开了个头. 贵在坚持吧 抽时间介绍我的hexo安装历程吧,今天实在是有点困了,要睡觉了. ...

  2. UVALive-8201-BBP Formula

    8201-BBP Formula Time limit: 3.000 seconds In 1995, Simon Plouffe discovered a special summation sty ...

  3. 虚拟环境搭建Django项目

    下载虚拟环境包 pip install virtualenv 创建虚拟环境 virtualenv   env 进入env文件夹 cd env 进入Scripts文件夹 cd Scripts 启动虚拟环 ...

  4. C# 简单的区块链实现

    1.项目配置 首先新建一个 Asp.Net Core 项目,然后选择 Empty Project(空项目) 类型,建立完成后无需进行任何配置. 2.数据模型 这里我们来创建一个具体的区块数据模型,使用 ...

  5. MySQL绿色版mysql-5.7.17-winx64简洁安装教程

    1.解压MySQL绿色版,复制my-default.ini,修改名称为my.ini 2. 以下为my.ini文件 # For advice on how to change settings plea ...

  6. asp.net后台或前端获取TemplateField绑定的文本

    GridView中使用最多的一个是BoundField,还有一个是TemplateField 这两个各有其特点,BoundField的话比较简单,设置好DataField.HeaderText等就可以 ...

  7. 简介:google ctemplate:简单易用的文字模板(转载)

    转自:http://blog.csdn.net/aladdina/article/details/4531736 CTemplate 是一个简单实用.功能强大的文字模板(template langua ...

  8. C#判断字符串中含有多少个汉字

    private void button1_Click(object sender, EventArgs e) { ArrayList itemList = new ArrayList(); CharE ...

  9. centos安装配置jdk

    本文以jdk8为例. 1.下载安装包 1.1.官网:https://www.oracle.com/technetwork/java/javase/downloads/index.html 1.2.登录 ...

  10. vue的data里面的值是数组时,在更改其某一项的时候,怎么触发视图的重新渲染?

    1. 设置对象或数组的值:Vue.set(target,key,value) :2.删除对象或数组中元素: Vue.delete ( target,key) ;3. 数组对象直接修改属性,可以触发视图 ...