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

简单的字符串操作!。

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. 使用 MD5 加密 去重对插入的影响

    现在有3000条数据,需要插入到数据库中去,使用的是对链接进行MD5加密, hashcode = md5(str(item_url))然后在数据库中设置 hashcode 为UNIQUE索引 3000 ...

  2. IntelliJ IDEA设置代码括号对齐方式

    IntelliJ IDEA设置代码括号对齐方式 IntelliJ IDEA默认的对齐方式如下:括号跟函数名在一行 想改为括号独自占一行,如下: 配置方式如下:File->Setting-> ...

  3. python2 与 python3的区别总结

    python2 与 python3的区别总结    几乎所有的Python 2程序都需要一些修改才能正常地运行在Python 3的环境下.为了简化这个转换过程,Python 3自带了一个叫做2to3的 ...

  4. [置顶] app后端设计--总目录

    版权声明:本文为博主原创文章,未经博主允许不得转载. 做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,Android客户端,iphone客户端,现就职于app云后 ...

  5. ConEmu配置task的脚本

    1.Bash::Msys2-64 set CHERE_INVOKING= & set .exe -new_console:p %ConEmuDrive%\msys64\usr\bin\bash ...

  6. distill 来自google,openai,deepmind,YC research

    https://distill.pub/ https://colah.github.io/

  7. docker使用示例

    本文使用docker容器运行wordpress博客,采用了三种方法来演示,docker的使用 自建wordpress容器 采用官方的wordpress容器 采用docker compose容器管理工具 ...

  8. HBase写入性能及改造——multi-thread flush and compaction(续:详细测试数据)[转]

    转载:http://blog.csdn.net/kalaamong/article/details/7290192 接上文啊: 测试机性能 CPU 16* Intel(R) Xeon(R) CPU   ...

  9. SQL2008R2 安装图解

    安装SQL Server 2008 R2需要.NET Framework 3.5 SP1支持 这里我们的操作系统是Windows Server 2008 R2,已经默认自带了.NET Framewor ...

  10. C# 去除json字符串key引号

    采用正则表达式去除: 方法 /// <summary> /// 去除json key双引号 /// </summary> /// <param name="js ...