题意就是将第一个字符串转化为第二个字符串,支持两个操作。一个是删除,一个是更换字符位置。

简单的字符串操作!。

AC代码例如以下:

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define M 50010
#define inf 100000000
using namespace std; char a[1005],b[1005];
int la,lb; bool automaton()
{
int i=0,j=0,flag=0;
while(a[i]!='\0')
{
if(a[i]==b[j])
{
i++;
j++;
flag++;
}
else
{
i++;
}
}
if(flag==lb) return true;
return false;
} int main()
{
int i,j;
int c[500],d[500];
cin>>a;
cin>>b;
la=strlen(a);
lb=strlen(b);
if(lb>la)
{
printf("need tree\n");
return 0;
}
if(la==lb)
{
memset(c,0,sizeof c);
memset(d,0,sizeof d);
for(i=0;i<la;i++)
c[a[i]]++;
for(i=0;i<lb;i++)
d[b[i]]++;
int ans=0;
for(i='a';i<='z';i++)
if(c[i]==d[i])
ans++;
if(ans==26)
{
printf("array\n");
return 0;
}
}
else if(automaton())
{
printf("automaton\n");
return 0;
}
memset(c,0,sizeof c);
memset(d,0,sizeof d);
int anss=0;
for(i=0;i<lb;i++)
d[b[i]]++;
for(i=0;i<la;i++)
c[a[i]]++;
for(i='a';i<='z';i++)
if(d[i]!=0)
anss++;
int an=0;
for(i='a';i<='z';i++)
if(c[i]>=d[i]&&d[i]!=0)
an++;
//cout<<an<<" "<<anss<<endl;
if(an==anss)
{
printf("both\n");
return 0;
}
printf("need tree\n"); return 0;
}

Codeforces Round #256 (Div. 2) B (448B) Suffix Structures的更多相关文章

  1. Codeforces Round #306 (Div. 2) ABCDE(构造)

    A. Two Substrings 题意:给一个字符串,求是否含有不重叠的子串"AB"和"BA",长度1e5. 题解:看起来很简单,但是一直错,各种考虑不周全, ...

  2. Codeforces Round #309 (Div. 1) A(组合数学)

    题目:http://codeforces.com/contest/553/problem/A 题意:给你k个颜色的球,下面k行代表每个颜色的球有多少个,规定第i种颜色的球的最后一个在第i-1种颜色的球 ...

  3. Codeforces Round #327 (Div. 2)B(逻辑)

    B. Rebranding time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  4. Codeforces Round #254 (Div. 2)D(预计)

    D. DZY Loves FFT time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  5. Codeforces Round #260 (Div. 1) Boredom(DP)

    Boredom time limit per test 1 second memory limit per test 256 megabytes input standard input output ...

  6. Codeforces Round #392(Div 2) 758F(数论)

    题目大意 求从l到r的整数中长度为n的等比数列个数,公比可以为分数 首先n=1的时候,直接输出r-l+1即可 n=2的时候,就是C(n, 2)*2 考虑n>2的情况 不妨设公比为p/q(p和q互 ...

  7. Codeforces Round #532 (Div. 2)- B(思维)

    Arkady coordinates rounds on some not really famous competitive programming platform. Each round fea ...

  8. Codeforces Round #254 (Div. 2) B (445B)DZY Loves Chemistry

    推理可得终于结果为2的(n-可分组合数)次方. 问题是怎么求出可分组合数,深搜就可以,当然并查集也能够. AC代码例如以下: 深搜代码!!! #include<iostream> #inc ...

  9. Codeforces Round #597 (Div. 2)D(最小生成树)

    /*每个点自己建立一座发电站相当于向超级源点连一条长度为c[i]的边,连电线即为(k[i]+k[j])*两点间曼哈顿距离,跑最小生成树(prim适用于稠密图,kruscal适用于稀疏图)*/ #def ...

随机推荐

  1. ansible 批量推送公钥

    这里我们使用ansible的playbook 的功能来推送秘钥 使用方法参见:http://blog.csdn.net/magedu_linux/article/details/48529645 这里 ...

  2. OAuth 2.0介绍

    简介 OAuth是一个关于授权(authorization)的开放网络标准,在全世界得到广泛应用,目前的版本是2.0版. 一.应用场景 为了理解OAuth的适用场合,让我举一个假设的例子. 有一个&q ...

  3. android 中毛玻璃效果的实现

    最近在做一款叫叽叽的App(男银懂的),其中有一个功能需要对图片处理实现毛玻璃的特效 进过一番预研,找到了3中实现方案,其中各有优缺点: 1.如果系统的api在16以上,可以使用系统提供的方法直接处理 ...

  4. ubuntu svn rabbitvcs 安装

    参考链接:http://blog.csdn.net/weng_xianhu/article/details/10079179 32位系统完全按照上面链接安装没有问题,但是如果是64位系统,第六步下载资 ...

  5. 从头认识java-15.7 Map(5)-介绍HashMap的工作原理-Key变了,能不能get出原来的value?(偶尔作为面试题)

    这一章节我们讨论一个比較特殊的情况Key变了,能不能get出原来的value? 答案是:有时能够,有时不能够 1.能够的情况: package com.ray.ch14; import java.ut ...

  6. Android 自定义Dialog 去除阴影

    自定义Dialog中添加下列代码: window.clearFlags( WindowManager.LayoutParams.FLAG_DIM_BEHIND);

  7. Gartner 2018新技术成熟度曲线

    https://blog.csdn.net/BtB5e6Nsu1g511Eg5XEg/article/details/82047719 近日,Gartner发布了2018年新技术成熟度曲线,首次将生物 ...

  8. (转)Go和HTTPS

    转自:http://studygolang.com/articles/2946 Go和HTTPS  2015-04-30   bigwhite  阅读 5688 次   4 人喜欢  3 条评论  收 ...

  9. raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found 解决办法

    报错信息如下: Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a5/e9/51b544da85a36a68debe7a7091f068d ...

  10. 【ARM】2410裸机系列-流水灯

    开发环境   1.硬件平台:FS2410(s3c2410) 2.主机:Ubuntu 12.04 LTS LED原理图 LED的GPIO的配置 配置GPFCON寄存器,设置GPF4-7为输出 配置GPF ...