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<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-字典序)

时间: 2024-11-05 00:38:09

ACdream 1125(ACfun-字典序)的相关文章

ACdream 之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

ACdream ACfun

题目不难,但因为个人英语不好. . ... 百度了下.题目意思是要求出字典序最小的而且不是所输入字符的子串: 也就是输出最多的连续的A: 假设没有A,输出一个A: #include<stdio.h> #include<string.h> int main() { int a,i,j,b,c,d; char t[105]; scanf("%d",&a); while(a--) { d=1; scanf("%s",t); b=strlen

【java】java反射机制,动态获取对象的属性和对应的参数值,并属性按照字典序排序,Field.setAccessible()方法的说明【可用于微信支付 签名生成】

方法1:通过get()方法获取属性值 package com.sxd.test.controller; public class FirstCa{ private Integer num; private String name; private Boolean flag; public Integer getNum() { return num; } public void setNum(Integer num) { this.num = num; } public String getNam

字典序排序-求全排列(元素有重复)

思路:数组a的元素分别是1,2,3,3:字典序排序就是找到下一个比1,2,3,3大的数组序列,即1,3,2,3: 步骤如下:1.首先使用Arrays.sort()对待排序数组进行排序:比如输入3213,排序后变成1233:从数组最后一个元素起(即i = 数组长度),将a[i]和a[i-1]比较,找到第一个a[i-1]<a[i]的i-1; 2,此时,a[i]前面可能还存在比a[i-1]大的元素,从数组末尾开始找到第一个比a[i-1]大的元素x,将x和a[i-1]交换,对Arrays.sort(a,

拼接最小字典序

转载请标明出处http://www.cnblogs.com/haozhengfei/p/63b2460bceae42e55f0c2d150bde663b.html 拼接最小字典序 拼接最小字典序练习 第8节 拼接最小字典序练习题 对于一个给定的字符串数组,请找到一种拼接顺序,使所有小字符串拼接成的大字符串是所有可能的拼接中字典序最小的. 给定一个字符串数组strs,同时给定它的大小,请返回拼接成的串. 测试样例: ["abc","de"],2 "abcde

POJ 2337 【字典序】【欧拉回路】

题意: 给你一些单词,判断这些单词能否在保证首尾单词相同的情况下连成一排. 如果有多组解,输出字典序最小的一组解. 这题... WA了两天. 错误有以下: 1.没有初始化好起始位置,默认起始位置是a了.想想想如果单词中都不带a开头的不就傻逼了吗. 2.没有理解好字典序,觉得只要保证每次都从

poj_1037 动态规划+字典序第k大

题目大意 给定n个数字,规定一种 cute 排序:序列中的数字大小为严格的波浪形,即 a[0] > a[1] < a[2] > a[3] < .... 或者 a[0] < a[1] > a[2] < a[3] ......对于N个数字来说,可以构成多个cute序列,这些序列按照字典序进行排序,求出第k个序列. 题目分析 一.求字典序的第i个排列 直接一位一位枚举答案!从前到后枚举求得每一位:枚举一位时,计算在这样的前缀下,后面的总的排列数.如果严格小于总编号,则该

ACdream 1203 - KIDx&#39;s Triangle(解题报告)

KIDx's Triangle Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submit Statistic Next Problem Problem Description One day, KIDx solved a math problem for middle students in seconds! And than he created this problem. N

acdream 1738 世风日下的哗啦啦族I

原题链接:http://acdream.info/problem?pid=1738 树套树裸题,如下: 1 #include<algorithm> 2 #include<iostream> 3 #include<cstdlib> 4 #include<cstring> 5 #include<cstdio> 6 #define lc root<<1 7 #define rc root<<1|1 8 using std::so