zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    一起学Windows Phone7开发(十三.六 Web控件)
    一起学Windows Phone7开发(十三.四 基本控件)
    一起学Windows Phone7开发(十三.一 容器控件)
    一起学Windows Phone7开发(十三.八 ListBox控件)
    一起学Windows Phone7开发(十三.九 UserControl控件)
    一起学Windows Phone7开发(十三.七 绘图控件)
    转载:MTU值的设置
    Uri(uniform resource identifiers)的用法
    用MeasureOverride和ArrangeOverride实现元素定位
    WPF窗体的关闭
  • 原文地址:https://www.cnblogs.com/fraud/p/4397193.html
Copyright © 2011-2022 走看看