博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #256 (Div. 2) B Suffix Structures
阅读量:7077 次
发布时间:2019-06-28

本文共 2650 字,大约阅读时间需要 8 分钟。

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 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.

Input

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.

Output

In the single line print the answer to the problem. Print "need tree" (without the quotes) if word s cannot be transformed into word t even 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.

Sample test(s)
Input
automaton tomat
Output
automaton
Input
array arary
Output
array
Input
both hot
Output
both
Input
need tree
Output
need tree
Note

In the third sample you can act like that: first transform "both" into "oth" by removing the first character using the suffix automaton and then make two swaps of the string using the suffix array and get "hot".

1 #include
2 #include
3 int n,i,j,l1,l2,a[26],b[26]; 4 char s[101],t[101]; 5 int main() 6 { 7 scanf("%s",s); 8 scanf("%s",t); 9 l1=strlen(s);10 l2=strlen(t);11 for(i=0;i
View Code

 

转载地址:http://kvdml.baihongyu.com/

你可能感兴趣的文章
Angular通过订阅观察者对象实现不同组件中数据的实时传递
查看>>
Bitmap的图片压缩汇总
查看>>
树莓派学习手记——制作一个空调遥控器(红外接收、发射的实现)
查看>>
《Maven实战》阅读总结(二)Maven仓库
查看>>
【369天】每日项目总结系列106(2018.02.09)
查看>>
WordPress 主题开发:从入门到精通(必读)
查看>>
Vue入坑记
查看>>
#ReactApp项目构建流程【3】
查看>>
canal 1.0.25 快速启动配置
查看>>
SpringBoot使用AOP+注解实现简单的权限验证
查看>>
Android 8.0 系统和API的变化
查看>>
Git 多人协作开发流程
查看>>
js 时间对象的常规操作
查看>>
BiuJS[v1.0]说明文档(2):数据劫持
查看>>
Centos 7 Yum方式安装Mongdb 3.4
查看>>
遇见大数据可视化 : 【云图】让数据可见
查看>>
Mac Docker 创建第一个Django 应用,Part 1
查看>>
zendAPI 的 CMake 参数详解
查看>>
【201天】黑马程序员27天视频学习笔记【Day18复习脑图】
查看>>
vue+webpack搭建单文件应用和多文件应用webpack.config.js的写法区别
查看>>