BestCoder Round #36 (hdu5198)Strange Class(水题)

时间:2022-12-07 18:51:26

转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud

Strange Class

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Problem Description
In Vivid’s school, there is a strange class(SC). In SC, the students’ names are very strange. They are in the same format: anbncn(a,b,c must not be the same with each other). For example studens whose names are“abc”,”ddppqq” are in SC, however studens whose names are “aaa”,“ab”,”ddppqqq” are not in SC.
Vivid makes friends with so many students, he wants to know who are in SC.
Input
There are multiple test cases (about 10), each case will give a string S which is the name of Vivid’s friend in a single line.
Please process to the end of file.

[Technical Specification]

1≤|S|≤10.

|S| indicates the length of S.

S only contains lowercase letter.

Output
For each case, output YES if Vivid’s friend is the student of SC, otherwise output NO.
Sample Input
abc
bc
Sample Output
YES
NO

必须是连续的字母。。。被坑了

 //#####################
//Author:fraud
//Blog: http://www.cnblogs.com/fraud/
//#####################
#include <iostream>
#include <sstream>
#include <ios>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cctype>
using namespace std;
#define XINF INT_MAX
#define INF 0x3FFFFFFF
#define MP(X,Y) make_pair(X,Y)
#define PB(X) push_back(X)
#define REP(X,N) for(int X=0;X<N;X++)
#define REP2(X,L,R) for(int X=L;X<=R;X++)
#define DEP(X,R,L) for(int X=R;X>=L;X--)
#define CLR(A,X) memset(A,X,sizeof(A))
#define IT iterator
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<PII> VII;
typedef vector<int> VI;
int vis[];
int num[];
int main()
{
ios::sync_with_stdio(false);
string s;
while(cin>>s){
int len=s.length();
CLR(vis,);
CLR(num,);
int ans=;
int cs=;
int k=len/;
if(k*!=len)ans=;if(ans){
char str=s[];
for(int i=;i<k;i++){
if(s[i]!=str)ans=;
}
str=s[k];
if(s[k]==s[k-])ans=;
for(int i=k;i<len-k;i++){
if(s[i]!=str)ans=;
}
str=s[len-k];
if(str==s[len-k-])ans=;
if(str==s[])ans=;
for(int i=len-k;i<len;i++){
if(s[i]!=str)ans=;
}
}
if(ans)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
} return ;
}