首页 web前端 html教程 Codeforces Round #256 (Div. 2) B. Suffix Structures(模拟)_html/css_WEB-ITnose

Codeforces Round #256 (Div. 2) B. Suffix Structures(模拟)_html/css_WEB-ITnose

Jun 24, 2016 pm 12:01 PM
round 模拟

题目链接:http://codeforces.com/contest/448/problem/B


----------------------------------------------------------------------------------------------------------------------------------------------------------
登录后复制
登录后复制
欢迎光临天资小屋:http://user.qzone.qq.com/593830943/main
登录后复制
----------------------------------------------------------------------------------------------------------------------------------------------------------
登录后复制
登录后复制



B. Suffix Structures

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

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

Sample test(s)

input

automatontomat
登录后复制

output

automaton
登录后复制

input

arrayarary
登录后复制

output

array
登录后复制

input

bothhot
登录后复制

output

both
登录后复制

input

needtree
登录后复制

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


代码如下:

#include <iostream>#include <algorithm>using namespace std;#define N 47#define M 100000#include <cstring>int a[N],b[N];char s[M+17], t[M+17];void init(){	memset(a,0,sizeof(a));	memset(b,0,sizeof(b));}int main(){	int i, j;	while(cin >> s)	{		init();		cin>>t;		int lens = strlen(s);		int lent = strlen(t);		for(i = 0; i = lens) //表示不存在不交换s子串的顺序能组成t的情况			{				p = 1;				break;			}			j++;		}		if(p == 1)		{			cout   <br>   <br>   <p></p>    <br>  <p></p> </cstring></algorithm></iostream>
登录后复制
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
3 周前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

php中的round是什么意思 php中的round是什么意思 Mar 10, 2023 am 10:04 AM

在php中,round的意思为“四舍五入”,是一个内置函数,作用是将浮点数转换为整数;该函数可以对浮点数进行四舍五入,并返回一个float类型的整数值,语法“round(number,precision,mode);”。

AI模拟器拿下物理仿真新SOTA! AI模拟器拿下物理仿真新SOTA! Feb 19, 2024 pm 06:50 PM

机器学习让计算机图形学(CG)仿真更真实了!方法名为神经流向图(NeuralFlowMaps,NFM),四个涡旋的烟雾也能精确模拟的那种:更为复杂的也能轻松实现:要知道,在这个AI应用满天飞的时代,CG物理仿真仍然是传统数值算法的天下。△NFM模拟“蛙跳”尽管神经网络应用在CG能创造目眩神迷的视觉效果,它却无法严格、鲁棒地描述物理性质。△NFM模拟“墨滴”也正是因此,基于神经网络的物理仿真至今还处于概念验证(proofofconcept)的阶段,所生成的效果也远非SOTA。为了解决这个复杂问题,

把Transformer当通用计算机用,还能执行in-context learning算法,这项研究脑洞大开 把Transformer当通用计算机用,还能执行in-context learning算法,这项研究脑洞大开 Apr 13, 2023 am 11:31 AM

Transformer 已成为各种机器学习任务的热门选择,并且取得了很好的效果,那它还能怎么用?脑洞大开的研究者竟然想用它来设计可编程计算机!这篇论文的作者来自普林斯顿大学和威斯康星大学,标题为《Looped Transformers as Programmable Computers》,旨在探索如何用 Transformer 来实现通用计算机。具体来说,作者提出了一个将 transformer 网络用作通用计算机的框架,方法是使用特定权重对它们进行编程并将它们置于循环(loop)中。在这个框架

如何用PHP的round()函数进行除以四舍五入 如何用PHP的round()函数进行除以四舍五入 Mar 21, 2023 pm 04:32 PM

round() 函数是PHP数字格式化库中一个非常实用的函数,可以将浮点数四舍五入到指定的小数位数。但是,由于PHP的除法运算可能会出现无限小数或精度丢失的问题,因此对除数进行四舍五入也很必要。接下来,我们会详细讲解如何使用PHP的round()函数进行除以四舍五入。

MySQL中如何使用ROUND函数截取小数位数 MySQL中如何使用ROUND函数截取小数位数 Jul 13, 2023 pm 09:21 PM

MySQL中如何使用ROUND函数截取小数位数在MySQL中,可以使用ROUND函数来截取小数的位数。ROUND函数可以把一个数字四舍五入到指定的小数位数。下面将为您详细介绍ROUND函数的使用方法,并提供代码示例。语法:ROUND(X,D)X表示要四舍五入的数字,D表示要保留的小数位数。使用ROUND函数截取小数位数的示例:假设有一个表格名为produc

三星收购英国知识图谱初创公司 本地 AI 模拟人类思考方式处理任务 三星收购英国知识图谱初创公司 本地 AI 模拟人类思考方式处理任务 Jul 19, 2024 pm 12:44 PM

近日,三星公司宣布收购英国知识图谱初创公司OxfordSemanticTechnologies,增强其本地AI功能,为用户提供更个性化的AI体验。该公司主要产品是AI引擎RDFox,通过知识图谱技术,将信息存储为互联网络,处理数据的方式类似于人类的思考方式:获取、记忆、回忆和推理知识。这技术将增强设备对用户使用产品或服务的理解,从而实现快速信息检索和推荐。据了解,OxfordSemanticTechnologies成立于2017年,由三位牛津大学教授伊恩·霍罗克斯、鲍里斯·莫蒂克和贝尔纳多·昆卡

PHP和WebDriver扩展:如何模拟用户的滚动和拖拽行为 PHP和WebDriver扩展:如何模拟用户的滚动和拖拽行为 Jul 07, 2023 pm 04:15 PM

PHP和WebDriver扩展:如何模拟用户的滚动和拖拽行为随着网络应用的不断发展,越来越多的网站和应用程序需要模拟用户的滚动和拖拽行为。这对于测试人员和开发人员来说是非常重要的,以确保网站和应用程序在各种场景下都能正常工作。在本文中,我们将介绍如何使用PHP和WebDriver扩展来模拟用户的滚动和拖拽行为。WebDriver是一个用于自动化浏览器的工具,

如何利用GitLab进行API测试和模拟 如何利用GitLab进行API测试和模拟 Oct 27, 2023 pm 05:35 PM

如何利用GitLab进行API测试和模拟引言:在进行软件开发过程中,API(ApplicationProgrammingInterface,应用程序编程接口)测试和模拟是非常重要的一步,它可以帮助开发人员验证API的正确性和性能,并且可以提前发现潜在的问题。GitLab是一个非常流行的代码托管平台,实现了版本控制和团队协作等功能。本文将介绍如何利用Git

See all articles