ACdream 1125(ACfun-字典序)

A - ACfun

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

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<AC

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


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cmath>
#include<cctype>
#include<ctime>
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<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;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;
}





你可能感兴趣的:(ACdream 1125(ACfun-字典序))