Codeforces Round #256 (Div. 2) B
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 transform word s into word t". The task
looked simple to the guys because they know the suffix data structures well. Bizon Senior loves suffix automaton. By applying it once to a string, he can remove from this string any single character. Bizon Middle knows suffix array well. By applying it once
to a string, he can swap any two characters of this string. The guys do not know anything about the suffix tree, but it can help them do much more.
Bizon the Champion wonders whether the "Bizons" can solve the problem. Perhaps, the solution do not require both data structures. Find out whether the guys can solve the problem and if they can, how do they do it? Can they solve it either only with use of suffix
automaton or only with use of suffix array or they need both structures? Note that any structure may be used an unlimited number of times, the structures may be used in any order.
The first line contains a non-empty word s. The second line contains a non-empty word t.
Words s and t are different. Each word consists
only of lowercase English letters. Each word contains at most 100 letters.
In the single line print the answer to the problem. Print "need tree" (without the quotes) if word s cannot
be transformed into word teven with use of both suffix array and suffix automaton. Print "automaton"
(without the quotes) if you need only the suffix automaton to solve the problem. Print "array" (without the quotes) if you need only the suffix array to solve
the problem. Print "both" (without the quotes), if you need both data structures to solve the problem.
It's guaranteed that if you can solve the problem only with use of suffix array, then it is impossible to solve it only with use of suffix automaton. This is also true for suffix automaton.
automaton
tomat
automaton
array
arary
array
both
hot
both
need
tree
need tree
AC代码:
#include<cstdio>
#include<cstring>
int n,i,j,l1,l2,a[26],b[26];
char s[101],t[101];
int main()
{
scanf("%s",s);
scanf("%s",t);
l1=strlen(s);
l2=strlen(t);
for(i=0;i<l1;++i)++a[s[i]-'a'];
for(i=0;i<l2;++i)++b[t[i]-'a'];
for(i=0;i<26;++i)if(a[i]<b[i])break;
if(i<26)
printf("need tree\n");
else{
for(i=j=0;i<l2&&j<l1;++i,++j)while(j<l1&&s[j]!=t[i])++j;
printf("%s\n",i<l2?(l1==l2?"array":"both"):"automaton");
}
return 0;
}
Codeforces Round #256 (Div. 2) B的更多相关文章
- Codeforces Round #256 (Div. 2) D. Multiplication Table(二进制搜索)
转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...
- Codeforces Round #256 (Div. 2) B. Suffix Structures(模拟)
题目链接:http://codeforces.com/contest/448/problem/B --------------------------------------------------- ...
- Codeforces Round #256 (Div. 2/B)/Codeforces448B_Suffix Structures(字符串处理)
解题报告 四种情况相应以下四组数据. 给两字符串,推断第一个字符串是怎么变到第二个字符串. automaton 去掉随意字符后成功转换 array 改变随意两字符后成功转换 再者是两个都有和两个都没有 ...
- Codeforces Round #256 (Div. 2) 题解
Problem A: A. Rewards time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces Round #256 (Div. 2) A. Rewards
A. Rewards time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- Codeforces Round #256 (Div. 2) D. Multiplication Table 二分法
D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input st ...
- Codeforces Round #256 (Div. 2) D. Multiplication Table
主题链接:http://codeforces.com/contest/448/problem/D 思路:用二分法 code: #include<cstdio> #include<cm ...
- Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)
解题报告 意思就是说有n行柜子,放奖杯和奖牌.要求每行柜子要么全是奖杯要么全是奖牌,并且奖杯每行最多5个,奖牌最多10个. 直接把奖杯奖牌各自累加,分别出5和10,向上取整和N比較 #include ...
- Codeforces Round #256 (Div. 2) D. Multiplication Table 很有想法的一个二分
D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces Round #256 (Div. 2)A-D
题目连接:http://codeforces.com/contest/448 A:给你一些奖杯与奖牌让你推断能不能合法的放在给定的架子上.假设能够就是YES否则就是NO. <span style ...
随机推荐
- ThinkPHP3.2.3扩展之自动分词获取关键字
ThinkPHP自动获取关键词调用在线discuz词库 先按照下图路径放好插件 /** * 自动获取关键词(调用第三方插件) * @return [type] [description] * www. ...
- netty之ByteBuf详解
[ChannelPromise作用:可以设置success或failure 是为了通知ChannelFutureListener]Netty的数据处理API通过两个组件暴露——abstract cla ...
- WebService的概念
一.序言 大家或多或少都听过 WebService(Web服务),有一段时间很多计算机期刊.书籍和网站都大肆的提及和宣传WebService技术,其中不乏很多吹嘘和做广告的成 分.但是不得不承认的是W ...
- [转]"RDLC"报表-参数传递及主从报表
本文转自:http://www.cnblogs.com/yjmyzz/archive/2011/09/19/2180940.html 今天继续学习RDLC报表的“参数传递”及“主从报表” 一.先创建D ...
- 认识JDK、JRE、JVM
JDK.JRE.JVM之间的关系: 首先看看JDK与JRE的区别与联系,如下图所示: 由图可知: JDK = JRE + Tools&Tool APIs JDK的核心是Java SE API. ...
- Windows 环境下 Docker 使用及配置
原文引用: https://www.cnblogs.com/moashen/p/8067612.html 我们可以使用以下两种方式在Windows环境下使用docker: 1. 直接安装: Docke ...
- Vue跨域访问,axios&cors
先安装node.js和npm,这个不用说了,直接在创建vue项目,然后实践一下跨域访问. 如果npm安装较慢,可安装淘宝镜像,执行下面命令: npm install -g cnpm --registr ...
- 查看Oracle数据库表空间大小,是否需要增加表空间的数据文件
在数据库管理中,磁盘空间不足是DBA都会遇到的问题,问题比较常见. --1查看表空间已经使用的百分比 Sql代码 select a.tablespace_name,a.bytes/1024/1024 ...
- Linux rsync配置用于服务器之间传输大量的数据
Linux的rsync 配置,用于服务器之间远程传大量的数据 [教程主题]:rsync [课程录制]: 创E [主要内容] [1] rsync介绍 Rsync(Remote Synchronize ...
- c# cookie帮助类
using System; using System.Collections.Generic; using System.Text; using System.Web; namespace Matic ...