ACdream 1125 (ACfun-lexicographically), acdreamacfun-
A-ACfun
Time Limit:2000/1000 MS (Java/Others)
Memory Limit:128000/64000 KB (Java/Others) SubmitStatusProblem DescriptionAs 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. inputThe 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. OutputFor each test case:
You shoshould output the string T meet the condition. Sample Input
1ACAC
Sample Output
AA
Lexicographic Order: AAAAA <AC
This question: Find the minimum lexicographic string T, which does not appear in S and only contains '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;}