# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
853811 | AndrijaM | Laugh Analysis (IOI16_laugh) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
const long long maxn=2e5+10;
const long long logn=23;
int n,q;
int main()
{
string s;
cin>>s;
n=s.size();
int ans=0;
for(int i=0;i<n;i++)
{
if(s[i]=='a' || s[i]=='h')
{
int j=i-1;
char k[2];
k[0]='a';
k[1]='h';
if(s[i]=='h')
{
swap(k[0],k[1]);
}
while(j+1<n && s[j+1]==k[0])
{
swap(k[0],k[1]);
j++;
}
ans=max(ans, j-i+1);
i=j;
}
}
cout<<ans<<endl;
return 0;
}
/*
7 1
1 1 1 1 1 1 1
1 3
1 2
3 7
2 4
2 5
2 6
2 2*/