这道题须要考虑的情况比較多,flag1表示情况是:b数组里有的字母而a里没有和b里面的同一个字母个数比a里面的多

flag2表示情况:b里面的左右字母能不能在a中同等顺序的存在

flag3表示情况:a里面同一个字母的个数与b里面是否同样

#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
// freopen("in.txt","r",stdin);
char a[105],b[105];
int coua[50],coub[50];
while(cin>>a>>b){
for(int i=0;i<50;i++)
coua[i]=coub[i]=0;
int lena=strlen(a);
int lenb=strlen(b);
for(int i=0;i<lena;i++)
coua[a[i]-'a']++;
for(int i=0;i<lenb;i++)
coub[b[i]-'a']++;
int flag1=0,flag2=0,flag3=0;
for(int i=0;i<50;i++){
if((coub[i]!=0 && coua[i]==0)||coub[i]>coua[i]){
flag1=1;
}
if(coub[i]!=coua[i])
flag3=1;
}
for(int i=0,j=0;i<lenb,j<lena;){
if(b[i]==a[j]){
i++;j++;
}else j++;
if(i==lenb)
flag2=1;
}
if((flag1==1 || lena<lenb)||((lena==lenb)&&flag3==1))
cout<<"need tree"<<endl;
if(flag1==0 && flag2==0 && lena>lenb )
cout<<"both"<<endl;
if(flag1==0 && flag2==1)
cout<<"automaton"<<endl;
if(flag1==0 && flag2==0 && lena==lenb && flag3==0)
cout<<"array"<<endl; }
}

B. Suffix Structures 模拟吧,情况比較多要想周全的更多相关文章

  1. Codeforces Round #256 (Div. 2) B. Suffix Structures(模拟)

    题目链接:http://codeforces.com/contest/448/problem/B --------------------------------------------------- ...

  2. cf448B Suffix Structures

    B. Suffix Structures time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. Codeforces Round #256 (Div. 2) B Suffix Structures

    Description Bizon the Champion isn't just a bison. He also is a favorite of the "Bizons" t ...

  4. chales抓包,模拟异常情况

    抓包能做什么? 1 .可以抓取客户端和server的请求和返回,可以借助判断是客户端问题是server问题 2.可以模拟各种异常情况用来测试异常情况 3.无接口文档情况下测试接口 怎么修改你抓到的请求 ...

  5. CONTINUE...?模拟分情况

    CONTINUE...? DreamGrid has  classmates numbered from  to . Some of them are boys and the others are ...

  6. CODE FESTIVAL 2017 qual A--C - Palindromic Matrix(模拟所有情况,注意细节)

    个人心得:其实本来这题是有规律的不过当时已经将整个模拟过程都构思出来了,就打算试试,将每个字符和总和用优先队列 装起来,然后枚举每个点,同时进行位置标志,此时需要多少个点的时候拿出最大的和出来,若不满 ...

  7. Codeforces Round #256 (Div. 2) B (448B) Suffix Structures

    题意就是将第一个字符串转化为第二个字符串,支持两个操作.一个是删除,一个是更换字符位置. 简单的字符串操作!. AC代码例如以下: #include<iostream> #include& ...

  8. codeforces 448B. Suffix Structures 解题报告

    题目链接:http://codeforces.com/problemset/problem/448/B 题目意思:给出两种操作automaton:可以删除字符串中任意一个字符: array:交换字符串 ...

  9. csacademy Round #36(模拟+最坏情况)

    传送门 题意 给出n种袜子,每种袜子个数a[i],两只相同种类袜子配成一对,询问至少拿出多少只袜子能确保配出k对袜子 分析 In order to find out the minimum numbe ...

随机推荐

  1. vue-cli脚手架引入element UI的正确打开方式

    element UI官网教程:http://element-cn.eleme.io/#/zh-CN/component/quickstart 1.完整引入,直接了当,但是组件文件不是按需加载,造成多余 ...

  2. 【python】日志系统

    来源: http://blog.csdn.net/wykgf/article/details/11576721 http://www.jb51.net/article/42626.htm http:/ ...

  3. Go语言建立一个最简单的服务端点

    handlers/handlers.go package handlers import ( "encoding/json" "net/http" ) func ...

  4. 服务器环境从PHP5升级到PHP7

    #安装ppa sudo apt-get install python-software-properties software-properties-common sudo add-apt-repos ...

  5. nginx 开启 gzip

    gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_comp_level 2; gzip_types text/plain applicatio ...

  6. cuda8.0 百度云盘分享

    因为深度学习的需要,装了ubuntu16系统,同时也装了cuda,在下载cuda的时候发现教育网下载的速度不忍直视,故换了更快的网下载,结果发现10兆宽带下载速度依然很慢,不过总算还是下载了,故把千辛 ...

  7. python 正则表达式匹配中文(转)

    网上的一篇文章,做了整理,作者已无从考证,谢谢了 s=""" en: Regular expression is a powerful tool for manipula ...

  8. 对TDD原则的理解

    1,在编写好失败的单元测试之前,不要编写任何产品代码    如果不先写测试,那么各个函数就会耦合在一起,最后变得无法测试    如果后写测试,你也许能对大块大块的代码进行测试,但是无法对每个函数进行测 ...

  9. Xamarin 中Visual Studio创建项目提示错误

    Xamarin 中Visual Studio创建项目提示错误 错误信息:Object reference not set to an instance of an object 出现这种情况,是由于没 ...

  10. hdu 1011(Starship Troopers,树形dp)

    Starship Troopers Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...