这道题须要考虑的情况比較多,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. 2017百度春招<度度熊买帽子的问题>

    题目: 度度熊想去商场买一顶帽子,商场里有N顶帽子,有些帽子的价格可能相同.度度熊想买一顶价格第三便宜的帽子,问第三便宜的帽子价格是多少? 数组中找到第三小的数字  注意边界条件 用STL中的set来 ...

  2. Python使用with结构打开多个文件

    同时打开三个文件,文件行数一样,要求实现每个文件依次读取一行,然后输出,我们先来看比较容易想到的写法: with open(filename1, 'rb') as f1: with open(file ...

  3. python基础(2)---数据类型

    1.python版本间的差异: 2.x与3.x版本对比 version 2.x 3.x print print " "或者print()打印都可以正常输出 只能print()这种形 ...

  4. LeetCode解题报告—— N-Queens && Edit Distance

    1. N-Queens The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no ...

  5. NYOJ 201 作业题

    作业题 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 小白同学这学期有一门课程叫做<数值计算方法>,这是一门有效使用数字计算机求数学问题近似解的方法与过 ...

  6. [图解算法]线性时间选择Linear Select——<递归与分治策略>

    #include <ctime> #include <iostream> using namespace std; template <class Type> vo ...

  7. margin和spacing的区别

    margin指的是与边框间的距离. spacing指的是组件间的距离

  8. gitlab备份与恢复

    (1)备份 1.创建备份目录,并授权 mkdir /data/backups/gitlab -pv chown -R git.git /data 2.修改gitlab配置 vim /etc/gitla ...

  9. react native android应用启动画面

    参考地址:https://www.youtube.com/watch?v=rnLR65OGtic 第一步:生成启动画面的背景图片 生成一个2048*2048的背景图片,打开网站https://apet ...

  10. flutter vscode插件

    代码片段