CodeForces
来源:互联网 发布:怎么一起网络看电影 编辑:程序博客网 时间:2024/05/18 03:37
题目链接:http://codeforces.com/problemset/problem/665/C点击打开链接
zscoder loves simple strings! A string t is called simple if every pair of adjacent characters are distinct. For example ab, aba, zscoderare simple whereas aa, add are not simple.
zscoder is given a string s. He wants to change a minimum number of characters so that the string s becomes simple. Help him with this task!
The only line contains the string s (1 ≤ |s| ≤ 2·105) — the string given to zscoder. The string s consists of only lowercase English letters.
Print the simple string s' — the string s after the minimal number of changes. If there are multiple solutions, you may output any of them.
Note that the string s' should also consist of only lowercase English letters.
aab
bab
caaab
cabab
zscoder
zscoder
对每三个数的中间那个数判断 看左右跟左右是否相等相等就改成跟那两个数不一样的
#include <iostream>#include <queue>#include <stdio.h>#include <stdlib.h>#include <stack>#include <limits.h>#include <string>#include <string.h>#include <vector>#include <set>#include <map>#include <algorithm>#include <math.h>#define maxn 101000using namespace std;int main(){ string s; cin >> s; for(int i=1;i<s.length();i++) { if(s[i-1]==s[i]) { for(int ii=0;ii<=3;ii++) if(s[i-1]!=ii+'a'&&s[i+1]!=ii+'a') { s[i]=ii+'a'; break; } } } cout << s;}
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- python
- ubuntu的man命令帮助如何设置中文版
- poi操作excel之: 将NUMERIC转换成TEXT
- ros学习笔记2-创建工作空间
- Java SE 1.6对synchronized的优化
- CodeForces
- 二叉树的下一个节点
- c++ 简化版lambda的介绍
- JavaScript学习(一) 数据类型
- 插入排序
- Nginx+Apache实现网页动静分离
- 苹果自动化之重签名
- Solr集群的搭建和使用(2)
- 2.编写第一个Quartz任务