ACdream 1125(ACfun-字典序)
A - ACfun
Problem Description
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
In each test case:
Input a string S consist of "A" and "C". The length of S is not large than 100.
Output
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-字典序)的更多相关文章
- ACdream 之ACfun 题解
A - ACfun Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) SubmitSta ...
- ACdream 速攻组~
1007 a + b /*这题就是一个快速幂,但是十分猥琐的是,模是1e10 + 7,不是1e9 + 7,这就产生了一个爆long long的问题.所以要对快速幂中的乘法操作进行一下改造.请教了BIT ...
- ACdream: ACfun
ACfun Time Limit: 2000/1000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others) SubmitStatisti ...
- CF724D. Dense Subsequence[贪心 字典序!]
D. Dense Subsequence time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- [poj2337]求字典序最小欧拉回路
注意:找出一条欧拉回路,与判定这个图能不能一笔联通...是不同的概念 c++奇怪的编译规则...生不如死啊... string怎么用啊...cincout来救? 可以直接.length()我也是长见识 ...
- java字典序全排列
import java.util.Arrays; /** *字典序全排列 *字符串的全排列 *比如单词"too" 它的全排列是"oot","oto&q ...
- noip模拟赛(10.4) 字典序(dictionary)
[题目描述] 你需要构造一个1~n的排列,使得它满足m个条件,每个条件形如(ai,bi),表示ai必须在bi前面.在此基础上,你需要使它的字典序最小. [输入数据] 第一行两个正整数n,m.接下来m行 ...
- 繁华模拟赛day8 字典序
/* 这个题要我们求一个字典序,字符串给出的顺序,会对字母的字典序前后相对顺序进行限定,如何用来表示这种限定,我们注意到这种一个之后接着一个,只有先输出他前面的才能输出他,很明显就是拓扑排序,最小方案 ...
- poj 1125 (floyd)
http://poj.org/problem?id=1125. 题意:在经纪人的圈子里,他们各自都有自己的消息来源,并且也只相信自己的消息来源,他们之间的信息传输也需要一定的时间.现在有一个消息需要传 ...
随机推荐
- 鼠标拖拽移动Java界面组件
默认的,Frame或者JFrame自身已经实现了鼠标拖拽标题栏移动窗口的功能. 只是,当你不满意java的JFrame样式,隐藏了标题栏和边框,又或者干脆直接使用JWindow,那你又该怎么实现鼠标拖 ...
- oracle创建临时表空间、用户表空间、创建用户关联表空间、授权等
1.创建临时表空间 CREATE TEMPORARY TABLESPACE test_temp TEMPFILE 'C:\oracle\product\10.1.0\oradata\orcl\test ...
- Codeforces_779_D.String Game_(二分)
D. String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard inpu ...
- context switch
In computing, a context switch is the process of storing and restoring the state (more specifically, ...
- day15-模块的基础及导入
目录 模块 什么是模块 使用模块 import 循环导入问题 解决方案一 解决方案二 模块的搜索路径 Python文件的两种用途 包 导入包内包 导入包内包的模块 绝对导入与相对导入 绝对导入 相对导 ...
- CAD制作简单动画
主要用到函数说明: IMxDrawEntity::Rotate 旋转一个对象.详细说明如下: 参数 说明 [in] IMxDrawPoint* basePoint 旋转基点 [in] DOUBLE d ...
- oracle_backup
#!/bin/bash DAYS=`date +"%Y%m%d"` . /home/oracle/.bash_profile # /home/opt/oracle/11g/bin/ ...
- 使用yolo3模型训练自己的数据集
使用yolo3模型训练自己的数据集 本项目地址:https://github.com/Cw-zero/Retrain-yolo3 一.运行环境 1. Ubuntu16.04. 2. TensorFlo ...
- iframe使用大全
<iframe src=”you page’s url” width=”100″ height=”30″ frameborder=”no” border=”0″ marginwidth=”0″ ...
- 搭建Nginx服务
Nginx 是一个高性能的 http 和反向代理服务器,也是一个 IMAP/POP3/SMPT 服务器. Nginx 是由 logor Sysoev 为俄罗斯访问第二的 Ranbler.ru 站点开发 ...