Codeforces Round #256 (Div. 2/B)/Codeforces448B_Suffix Structures(字符串处理)
automaton 去掉随意字符后成功转换
array 改变随意两字符后成功转换
再者是两个都有和两个都没有
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
using namespace std; int main()
{
char str1[110],str2[110];
int h1[100],h2[100],i,j;
while(cin>>str1>>str2)
{
memset(h1,0,sizeof(h1));
j=0;
int l1=strlen(str1),l2=strlen(str2);
for(i=0; i<l2,j<l1;)
{
if(str2[i]==str1[j])
{
j++;
i++;
}
else j++;
}
if(i==l2)
cout<<"automaton"<<endl;
else
{
for(i=0; i<l1; i++)
{
h1[str1[i]-'a']++;
}
for(i=0; i<l2; i++)
{
if(h1[str2[i]-'a'])
h1[str2[i]-'a']--;
else break;
}
if(i==l2&&l1==l2)
{
cout<<"array"<<endl;
}
else if(i==l2&&l1!=l2)
cout<<"both"<<endl;
else cout<<"need tree"<<endl; }
}
}
1 second
256 megabytes
standard input
standard output
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
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".
Codeforces Round #256 (Div. 2/B)/Codeforces448B_Suffix Structures(字符串处理)的更多相关文章
- Codeforces Round #256 (Div. 2) B. Suffix Structures(模拟)
题目链接:http://codeforces.com/contest/448/problem/B --------------------------------------------------- ...
- Codeforces Round #256 (Div. 2) B Suffix Structures
Description Bizon the Champion isn't just a bison. He also is a favorite of the "Bizons" t ...
- Codeforces Round #256 (Div. 2) B (448B) Suffix Structures
题意就是将第一个字符串转化为第二个字符串,支持两个操作.一个是删除,一个是更换字符位置. 简单的字符串操作!. AC代码例如以下: #include<iostream> #include& ...
- 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) D. Multiplication Table(二进制搜索)
转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...
- Codeforces Round #256 (Div. 2)
A - Rewards 水题,把a累加,然后向上取整(double)a/5,把b累加,然后向上取整(double)b/10,然后判断a+b是不是大于n即可 #include <iostream& ...
- 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 ...
随机推荐
- SGU131--NYOJ435
参考blog http://m.blog.csdn.net/blog/u012760629/36927465 http://www.cppblog.com/menrowitianya/archive/ ...
- linux的exec命令
linux的exec命令可以多进程执行,如果在浏览器访问使用http协议,会存在内存溢出和执行时间问题.
- (转)XML CDATA是什么?
解析数据 XML 解析器通常情况下会处理XML文档中的所有文本. 当XML元素被解析的时候,XML元素内部的文本也会被解析: <message>This text is also pars ...
- .net 实现 URL重写,伪静态
一,获得Mircosoft URLRewriter.dll: 获得Mircosoft URLRewriter.dll可以到http://www.microsoft.com/china/msdn/lib ...
- spark 操作hbase
HBase经过七年发展,终于在今年2月底,发布了 1.0.0 版本.这个版本提供了一些让人激动的功能,并且,在不牺牲稳定性的前提下,引入了新的API.虽然 1.0.0 兼容旧版本的 API,不过还是应 ...
- JavaWeb学习笔记之JSP(二)
1.1. JSP的指令: 1. 什么是JSP 指令? JSP 指令: JSP指令(directive)是为JSP引擎而设计的,它们并不直接产生任何可见输出, 而只是告诉引擎如何处理JSP页面中的 ...
- Uncaught TypeError: Cannot set property 'innerHTML' of null
学习Chrome插件时,要在弹出页面中显示当前时间,结果怎样也显示不出来 看了 http://www.cnblogs.com/mfryf/p/3701801.html 这篇文章后感悟颇深 通过调试发现 ...
- CentOS 7 之安装X Window System
网上说的直接 yum groupinstall "Desktop"经实验,在我的机器上是无效的.我使用的是: yum groupinstall 'GNOME Desktop' 才o ...
- 使用iframe调用指定网页的特定位置(显示目标网页某区域的我想要的内容)
使用iframe调用指定网页的特定位置(显示目标网页某区域的我想要的内容) 有些时候我们并不需要显示iframe标签属性src指定的目标网页的所有内容,往往只需要显示某一特定区域.现有两种实现方法提供 ...
- Cloudera Search配置
一.集群机器配置信息 Cloudera集群机器: 10.2.45.104 GBD000.localdomain GBD00010.2.45.105 GBD101.localdomain GBD1011 ...