您的位置:首页 > 其它

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

2015-04-06 23:50 330 查看
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud

Strange Class

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



[align=left]Problem Description[/align]
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.

[align=left]Input[/align]
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.

[align=left]Output[/align]
For each case, output YES if Vivid’s friend is the student of SC, otherwise output NO.

[align=left]Sample Input[/align]

abc
bc

[align=left]Sample Output[/align]

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[1010];
int num[1010];
int main()
{
ios::sync_with_stdio(false);
string s;
while(cin>>s){
int len=s.length();
CLR(vis,0);
CLR(num,0);
int ans=1;
int cs=0;
int k=len/3;
if(k*3!=len)ans=0;if(ans){
char str=s[0];
for(int i=0;i<k;i++){
if(s[i]!=str)ans=0;
}
str=s[k];
if(s[k]==s[k-1])ans=0;
for(int i=k;i<len-k;i++){
if(s[i]!=str)ans=0;
}
str=s[len-k];
if(str==s[len-k-1])ans=0;
if(str==s[0])ans=0;
for(int i=len-k;i<len;i++){
if(s[i]!=str)ans=0;
}
}
if(ans)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: