题目链接: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 101000
using 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;
}