codeforces Div.2 B.Suffix Structures

题意是给我们两个字符串,再在第一个字符串中找第二个,

给了我们两种方法,一:在第一个字符串删掉一些字符后得到第二个字符串;

二:在第一个字符串中改变一些字符的先后顺序得到字符串二;

如果只用第一种方法输出:   automaton;

只用第二种输出:array

两种都用输出:both;

找不到输出:need tree;

直接找就行,,,,,,水

#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
    char a[101],b[101];
    int s[101];
    int c,d,i,j;
    scanf("%s",a);
    scanf("%s",b);
    c=strlen(a);
    d=strlen(b);
    for(i=0,j=0;i<c;i++)
    {
        if(a[i]==b[j])
       {
           j++;
       }
       if(j==d)
        {printf("automaton\n");return 0;}
    }
    int e=0;
    memset(s,0,sizeof(s));
    for(int i=0;i<d;i++)
    {
        for(int j=0;j<c;j++)
        {
            if(s[j]!=1){
            if( b[i]==a[j])
            {
                s[j]=1;
                e++;
                break;
            }
            }
        }
    }
    if(e==d)
    {
        if(c==d)
            {printf("array\n");}
        if(c>d)
            printf("both\n");
    }
    else
    printf("need tree\n");
    return 0;
}

codeforces Div.2 B.Suffix Structures

时间: 2024-07-30 18:50:45

codeforces Div.2 B.Suffix Structures的相关文章

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

题目链接:http://codeforces.com/contest/448/problem/B ---------------------------------------------------------------------------------------------------------------------------------------------------------- 欢迎光临天资小屋:http://user.qzone.qq.com/593830943/ma

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

Bizon the Champion isn't just a bison. He also is a favorite of the "Bizons" team. At a competition the "Bizons" got the following problem: "You are given two distinct words (strings of English letters), s and t. You need to trans

#256 (Div. 2)B. Suffix Structures

题意:2种操作,第一种删除任意字符,第二种交换任意2个字符位置,如果能让A,B字符串相等,只用第一种操作输出automaton,只用第二种输出array,2种都用both ,否则输出need tree 思路:我们肯定先判断26个字母的使用情况,然后判断是否只需要用第一种操作,即B的字符顺序在A中有. 1 #include<bits/stdc++.h> 2 using namespace std; 3 4 int a[30],b[30]; 5 int main(){ 6 string s1,s2

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

题意就是将第一个字符串转化为第二个字符串,支持两个操作,一个是删除,一个是更换字符位置. 简单的字符串操作!! 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; b

Codeforces Round #256 (Div. 2/B)/Codeforces448B_Suffix Structures(字符串处理)

解题报告 四种情况相应以下四组数据. 给两字符串,推断第一个字符串是怎么变到第二个字符串. automaton 去掉随意字符后成功转换 array 改变随意两字符后成功转换 再者是两个都有和两个都没有 #include <iostream> #include <cstdio> #include <cstring> #include <stdlib.h> #include <algorithm> #include <cmath> usi

B. Suffix Structures 模拟吧,情况比较多要想周全

这道题需要考虑的情况比较多,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"

Codeforces Div.301D Bad Luck Island(概率dp+记忆化搜索)

一道概率dp问题. 题目链接:http://codeforces.com/contest/540/problem/D 题目大意:一个岛上有r个石头,s个剪子,p个布,他们之间随机挑出两个相遇,如果不是相同物种,就会有一个消失,分别求出最后这座岛上只剩下一个物种的概率. 我们用dp[i][j][k]来存储i个石头,j个剪刀,k个布时,某物种的存活概率,共dp三次,算出三个物种分别的概率. 首先,我们需要把对应想求的物种概率初始化,这里以石头为例,那么对于i从1到r,不难理解dp[i][0][0]=

Codeforces Round #256 (Div. 2) A/B/C/D

A. Rewards 水题 #include<cstdio> #include<iostream> #include<cstring> using namespace std; int main() { int a1,a2,a3,b1,b2,b3,s,t1,t2,sum1,sum2; while(scanf("%d%d%d",&a1,&a2,&a3)!=EOF) { scanf("%d%d%d",&

Codeforces Round #256 (Div. 2) B

B. Suffix Structures Bizon the Champion isn't just a bison. He also is a favorite of the "Bizons" team. At a competition the "Bizons" got the following problem: "You are given two distinct words (strings of English letters), s and