当前位置:网站首页>#796 Div.2 C. Manipulating History 思维
#796 Div.2 C. Manipulating History 思维
2022-06-27 22:15:00 【Strezia】
link
思维
题意
现有一个串 s s s, 初始只含一个字母,给出 2 n 2n 2n 个串,每次可以从中选2个串 t 1 , t 2 t_1,t_2 t1,t2,将 s s s 中子串 t 1 t_1 t1 替换为 t 2 t_2 t2,重复 n n n 次,现给出这 2 n 2n 2n 个串以及最终结果,求初始字母。
思路
统计给出的 2 n + 1 2n+1 2n+1 个串中每个字母的出现次数,为奇数的那个即为初始字母。
因为每个字母一定会在它加入的时候出现一次,然后在被删除(或保留到了最后)时出现一次。也就是一定出现了偶数次,只有初始字母在被替换的时候加入的一次。
代码
void solve() {
int n;
cin >> n;
vector<int> cnt(30);
for(int i = 1; i <= 2 * n + 1; i++) {
string s;
cin >> s;
for(auto i : s) {
cnt[i - 'a']++;
}
}
for(int i = 0; i < 30; i++) {
if(cnt[i] & 1) {
cout << char(i + 'a') << endl;
return;
}
}
}
边栏推荐
- request对象、response对象、session对象
- QStringList 的学习笔记
- ValidateRequest=”false” 是做什么的「建议收藏」
- What are the ways to combine the points system with marketing activities
- 积分体系和营销活动结合在一起有哪些玩法
- Alchemy (6): iteratable models and use cases
- Arduino UNO通过电容的直接检测实现简易触摸开关
- Count prime [enumeration - > space for time]
- 本地可视化工具连接阿里云centOS服务器的redis
- [读书摘要] 学校的英文阅读教学错在哪里?--经验主义和认知科学的PK
猜你喜欢
[digital ic/fpga] detect the position of the last matching sequence
[paper reading | deep reading] sdne:structural deep network embedding
Redis主从复制、哨兵模式、集群的概述与搭建
Alchemy (1): identify prototype, demo and MVP in project development
安全省油環保 駱駝AGM啟停電池魅力十足
技术的极限(11): 有趣的编程
Character interception triplets of data warehouse: substrb, substr, substring
What is promise
Software engineering job design (1): [personal project] implements a log view page
Sell notes | brief introduction to video text pre training
随机推荐
MATLB|改进的前推回代法求解低压配电网潮流
哪个证券公司炒股开户是比较好,更安全靠谱的
Feign implements path escape through custom annotations
MATLB|基于复杂网络的配电系统微电网优化配置
SCU|通过深度强化学习进行微型游泳机器人的步态切换和目标导航
MySQL分表查询之Merge存储引擎实现
Feign通过自定义注解实现路径的转义
夏日的晚会
Code neatness -- function
炼金术(3): 怎样做好1个业务流程的接口对接
数据仓库入门介绍
2022 PMP project management examination agile knowledge points (3)
RecyclerView实现分组效果,多种实现方式
认识微信小程序项目的基本组成结构
After a period of silence, I came out again~
Transmitting and receiving antenna pattern
券商买股票用什么app是比较好的,比较安全的
Technical debt wall: a way to make technical debt visible and negotiable
供应链高效管理供应商
NDSS 2022 received list