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

转载请注明出处: 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

 

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

 

 1 //#####################
 2 //Author:fraud
 3 //Blog: http://www.cnblogs.com/fraud/
 4 //#####################
 5 #include <iostream>
 6 #include <sstream>
 7 #include <ios>
 8 #include <iomanip>
 9 #include <functional>
10 #include <algorithm>
11 #include <vector>
12 #include <string>
13 #include <list>
14 #include <queue>
15 #include <deque>
16 #include <stack>
17 #include <set>
18 #include <map>
19 #include <cstdio>
20 #include <cstdlib>
21 #include <cmath>
22 #include <cstring>
23 #include <climits>
24 #include <cctype>
25 using namespace std;
26 #define XINF INT_MAX
27 #define INF 0x3FFFFFFF
28 #define MP(X,Y) make_pair(X,Y)
29 #define PB(X) push_back(X)
30 #define REP(X,N) for(int X=0;X<N;X++)
31 #define REP2(X,L,R) for(int X=L;X<=R;X++)
32 #define DEP(X,R,L) for(int X=R;X>=L;X--)
33 #define CLR(A,X) memset(A,X,sizeof(A))
34 #define IT iterator
35 typedef long long ll;
36 typedef pair<int,int> PII;
37 typedef vector<PII> VII;
38 typedef vector<int> VI;
39 int vis[1010];
40 int num[1010];
41 int main()
42 {
43     ios::sync_with_stdio(false);
44     string s;
45     while(cin>>s){
46         int len=s.length();
47         CLR(vis,0);
48         CLR(num,0);
49         int ans=1;
50         int cs=0;
51         int k=len/3;
52         if(k*3!=len)ans=0;if(ans){
53         char str=s[0];
54         for(int i=0;i<k;i++){
55             if(s[i]!=str)ans=0;
56         }
57         str=s[k];
58         if(s[k]==s[k-1])ans=0;
59         for(int i=k;i<len-k;i++){
60             if(s[i]!=str)ans=0;
61         }
62         str=s[len-k];
63         if(str==s[len-k-1])ans=0;
64         if(str==s[0])ans=0;
65         for(int i=len-k;i<len;i++){
66             if(s[i]!=str)ans=0;
67         }
68         }
69         if(ans)cout<<"YES"<<endl;
70         else cout<<"NO"<<endl;
71     }
72             
73     return 0;
74 }

 

转载于:https://www.cnblogs.com/fraud/p/4397193.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值