链接:

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. linux查看文件前几行和后几行的命令

        可以使用head(查看前几行).tail(查看末尾几行)两个命令.例如:查看/etc/profile的前10行内容,应该是:# head -n 10 /etc/profile查看/etc/pr ...

  2. maven profiles多环境配置

    maven profiles多环境配置 转载. https://blog.csdn.net/runbat/article/details/81747874 今天做了一个小项目,需要配置开发.测试.预发 ...

  3. 20191125:Python中的上下文管理机制with

    20191125:with上下文管理 with是一个上下文管理器,用于执行代码块所需要的运行的时候的上下文入口和出口.上下文管理器的典型用法包括保存和还原各种全局状态,锁定和解锁资源,关闭打开的文件等 ...

  4. 启动 docker 容器时报错

    错误信息: iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 9300 -j DNAT --to-dest ...

  5. 在论坛中出现的比较难的sql问题:17(字符分拆2)

    原文:在论坛中出现的比较难的sql问题:17(字符分拆2) 最近,在论坛中,遇到了不少比较难的sql问题,虽然自己都能解决,但发现过几天后,就记不起来了,也忘记解决的方法了. 所以,觉得有必要记录下来 ...

  6. jquery.fileupload源码解读笔记

    基础编程风格 新建 test.html  和 test.js和 main.js和 无论哪种顺序 <body> <script src="/Sandeep/js/jquery ...

  7. 记一次渗透某XX站

    0X00 前言 团队A师傅发来个站,问我有没有得搞 正好在搞其他的站,卡住了,开干换个思路. 0x01 信息收集 开burp抓了下包,目标设置了url重写,开了报错,我们随意输入一个控制器就直接报错. ...

  8. [LeetCode] 76. 最小覆盖子串 ☆☆☆☆☆(滑动窗口)

    https://leetcode-cn.com/problems/minimum-window-substring/solution/hua-dong-chuang-kou-suan-fa-tong- ...

  9. Cron 定时任务表达式

    Cron Cron表达式是一个字符串,字符串以5或6个空格隔开,分为6或7个域,每一个域代表一个含义,Cron有如下两种语法格式: Seconds Minutes Hours DayofMonth M ...

  10. java一些基本算法

    本文主要介绍一些常用的算法: 冒泡排序:两两相互之间进行比较,如果符合条件就相互兑换. //冒泡排序升序 public static int[] bubblingSortAsc(int[] array ...