#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;
 7     cin>>s1>>s2;
 8     for(int i=0;i<s1.size();i++){
 9         a[s1[i]-‘a‘]++;
10     }
11     for(int j=0;j<s2.size();j++){
12         b[s2[j]-‘a‘]++;
13     }
14     int t=0;
15     for(int i=0;i<26;i++){
16         if(a[i]<b[i]){
17             t=1;break;
18         }
19     }
20     if(t){
21         printf("need tree\n");
22     }
23     else {
24         if(s1.size()==s2.size()){
25             printf("array\n");return 0;
26         }
27         t=0;
28         int j=0;
29         for(int i=0;i<s1.size();i++){
30             if(s1[i]==s2[j]){
31                 j++;
32             }
33             if(j==s2.size()) {t=1;break;}
34         }
35         if(t){
36             printf("automaton\n");
37         }
38         else printf("both\n");
39     }
40     return 0;
41 }
时间: 2024-11-08 16:27:04

#256 (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

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

codeforces Div.2 B.Suffix Structures

题意是给我们两个字符串,再在第一个字符串中找第二个, 给了我们两种方法,一:在第一个字符串删掉一些字符后得到第二个字符串: 二:在第一个字符串中改变一些字符的先后顺序得到字符串二: 如果只用第一种方法输出:   automaton: 只用第二种输出:array 两种都用输出:both: 找不到输出:need tree: 直接找就行,,,,,,水 #include<stdio.h> #include<string.h> using namespace std; int main()

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) 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) 题解

Problem A: A. Rewards time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bizon the Champion is called the Champion for a reason. Bizon the Champion has recently got a present - a new glass cup

Codeforces #256 Div.2

B. Suffix Structure 1. 先判断s去掉一些元素是否能构成t,如果可以就是automaton 判断的方法也很简单,two pointer,相同元素同时++,不相同s的指针++,如果t能全找到,那么s能够去掉元素构成t. bool f(string s, string t) { int i = 0, j = 0; while (i < s.size() && j < t.size()) { if (s[i] == t[j]) { i++; j++; } else

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