#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
using namespace std; //CF Div211 (C)
//题意: 输入一个字符串中,输出时字符串中不能含有三个连续相同的字符,或者不能含有一对两个连续相同的字符(如aabb)
int main()
{
int n, t, j;
string s;
char a[200010];
while(scanf("%s", a)!=EOF)
{
n=strlen(a);
s.clear();
for(t=0, j=-1; t<n; ++t)
{
if(s.size()<2)
{
s+=a[t];
j++;
}
else
{
if(a[t]==s[j]&&s[j]==s[j-1])
continue;
if(s.size()>=3&&a[t]==s[j]&&s[j-1]==s[j-2])
continue;
s+=a[t];
j++;
}
}
cout<<s<<endl;
}
return 0;
}
CF Div211 (C)
最新推荐文章于 2024-08-14 00:58:46 发布