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 ...
随机推荐
- E20170816-mk
deque 即双端队列.是一种具有队列和栈的性质的数据结构. revert vi. 恢复; 重提; 回到…上; <律>归还; n. 归属; 恢复原来信仰的人; Indicator ...
- SpringAOP使用注解实现5种通知类型
spring aop的5种通知类型都有 Before前置通知 AfterReturning后置通知 Around环绕通知 AfterThrowing异常通知 After最终通知 首先创建接口和实现类 ...
- [Swift]LeetCode1066. 校园自行车分配 II | Campus Bikes II
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- Redis(五)-数据库
Redis是一个字典结构的存储服务器,而实际上一个Redis实例提供了多个用来存储数据的字典,客户端可以将制定的书存储在哪个字典中,这与关系书库实例中可以i创建多个数据库类似,所以可以将其中的每个字典 ...
- android view、viewgroup 事件响应拦截处理机制
文章中会用到部分网络资源,首先将原作者的链接附上. 但是还是会附上数量较大的关于此部分内容的自己的思考. ----------------------------------------------- ...
- node函数buf.readDoubleBE详解
offset {Number} 0 noAssert {Boolean} 默认:false 返回:{Number} 从该 Buffer 指定的带有特定尾数格式(readDoubleBE() 返回一个较 ...
- Beta冲刺-星期五
这个作业属于哪个课程 <课程的链接> 这个作业要求在哪里 <作业要求的链接> 团队名称 Three cobblers 这个作业的目标 完成项目最后的冲刺 ...
- ie8及其以下版本兼容性问题之input file隐藏上传文件
文件上传时,默认的file标签很难看,而且每个浏览器下都有很大差距.因此我们基本都把真正的file标签给隐藏,然后创建一个标签来替代它.但是由于IE出于安全方面的考虑上传文件时必须点击file的浏览按 ...
- 【SQL】INTERVAL YEAR TO MONTH 和 INTERVAL DAY TO SECOND
INTERVAL YEAR TO MONTH: 作为年和月的时间间隔存储 INTERVAL DAY TO SECOND: 作为天.小时.分和秒的时间间隔存储(DAY,HOUR,MINUTE,SECON ...
- 人脸Pose检测:ASM、AAM、CLM总结
人脸的Pose检测可以使用基于位置约束的特征点的方法.人脸特征点定位的目的是在人脸检测的基础上,进一步确定脸部特征点(眼睛.眉毛.鼻子.嘴巴.脸部外轮廓)的位置.定位算法的基本思路是:人脸的纹理特征和 ...