设为首页 加入收藏

TOP

ACdream 1125(ACfun-字典序)
2015-07-24 05:33:52 来源: 作者: 【 】 浏览:5
Tags:ACdream 1125 ACfun- 字典

A - ACfun

Time Limit: 2000/1000MS ( Java/Others) Memory Limit: 128000/64000KB (Java/Others) SubmitStatus

Problem Description

As a former ACMer, "AC" is a special abbreviated word which can bring much pleasure to me. Sometimes it means everything.
This problem is about "AC".
One day, I write a long string S on the paper which contains "A" and "C". Now I want to find a lexicographic minimum string T satisfied that T is distinct with all substring of S.

Input

The first line of input file contains an integer T indicating the number of case.
In each test case:
Input a string S consist of "A" and "C". The length of S is not large than 100.

Output

For each test case:
You should output the string T meet the condition.

Sample Input

1
ACAC

Sample Output

AA

字典序:AAAAA

本题:找字典序最小字符串T,其不在S中出现,只包含'A''C'


#include
   
    
#include
    
      #include
     
       #include
      
        #include
       
         #include
        
          #include
         
           #include
          
            #include
           
             using namespace std; #define For(i,n) for(int i=1;i<=n;i++) #define Fork(i,k,n) for(int i=k;i<=n;i++) #define Rep(i,n) for(int i=0;i
            
             =0;i--) #define Forp(x) for(int p=pre[x];p;p=next[p]) #define Lson (x<<1) #define Rson ((x<<1)+1) #define MEM(a) memset(a,0,sizeof(a)); #define MEMI(a) memset(a,127,sizeof(a)); #define MEMi(a) memset(a,128,sizeof(a)); #define INF (2139062143) #define F (100000007) #define MAXN (100000+100) long long mul(long long a,long long b){return (a*b)%F;} long long add(long long a,long long b){return (a+b)%F;} long long sub(long long a,long long b){return (a-b+(a-b)/F*F+F)%F;} typedef long long ll; char s[MAXN]; int main() { // freopen("A.in","r",stdin); // freopen(".out","w",stdout); int t; scanf("%d\n",&t); while (t--) { scanf("%s",s); int n=strlen(s),p=0,t=0; Rep(i,n) { if (s[i]=='A') p++;else p=0; t=max(t,p); }++t; while(t--) printf("A");printf("\n"); // else printf("%s\n",s); } return 0; } 
            
           
          
         
        
       
      
     
    
   





】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇POJ 3014:Asteroids(二分匹配,.. 下一篇C++中对象指针的使用

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: