Educational Codeforces Round 75 (Rated for Div. 2) A. Broken Keyboard
链接:
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的更多相关文章
- Educational Codeforces Round 75 (Rated for Div. 2)
知识普及: Educational使用拓展ACM赛制,没有现场hack,比赛后有12h的全网hack时间. rank按通过题数排名,若通过题数相等则按罚时排名. (罚时计算方式:第一次通过每题的时间之 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
随机推荐
- [转帖]MyCat教程【简单介绍】
MyCat教程[简单介绍] 2019-10-15 10:27:23 波波烤鸭 阅读数 618 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. ...
- 关于String Json 与其他类型数据转换的总结:
一:关于自己遇到的坑: 跨域请求获取到 String Json(GSON处理) 数据后处理转换为实体类进行存储: 跨域 return Gson.toJson(map): 通过Http等方法获取请求结果 ...
- 分布式系统领域的 CAP 定理
C 为数据一致性: A 为服务可用性: P 为服务对网络分区故障的容错性. 这三个特性在任何分布式系统中都不能同时满足,最多同时满足两个.
- PyCharm:设置py文件头部信息
P PyCharm:设置py文件头部信息file->setting->appearance & behavior->editor->file and code temp ...
- Python习题001
作业1 * 用条件语句写一个BMI(体重除以身高的平方)指数* 低于18.5:过轻* 18.5 - 25 正常* 25 - 28 过重* 28 - 32 肥胖* 高于32 严重肥胖 weight = ...
- Scala 算法案例
移除第一个负数之后的所有负数 // 构建数组 val a = ArrayBuffer[Int]() a += (1, 2, 3, 4, 5, -1, -3, -5, -9) // 每发现一个第一个负数 ...
- echarts饼状图位置设置
series: { name: "流量占比分布", type: "pie", radius: ["40%", "60%" ...
- SSL 杂谈
在电子邮件系统中的开发和维护中,由于安全性的需要,经常会遇到 SSL 相关的问题,这里整理下 SSL 的一些基础知识 什么是 SSL SSL (Secure Sockets Layer) 是一种在应用 ...
- 3.asp.net core 关键概念
1. StartUp类 在Startup.ConfigureServices方法里配置或注册服务 在Startup.Configure方法里配置请求处理管道.请求处理管道由一系列中间件组建构成,每个中 ...
- VBA字符串(十二)
字符串是一个字符序列,可以由字母,数字,特殊字符或全部字符组成. 如果一个变量被包含在双引号""中,则被认为是一个字符串. 语法 variable_name = "thi ...