首頁 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脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

<🎜>:泡泡膠模擬器無窮大 - 如何獲取和使用皇家鑰匙
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
北端:融合系統,解釋
1 個月前 By 尊渡假赌尊渡假赌尊渡假赌
Mandragora:巫婆樹的耳語 - 如何解鎖抓鉤
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
<🎜>掩蓋:探險33-如何獲得完美的色度催化劑
2 週前 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)

熱門話題

Java教學
1677
14
CakePHP 教程
1430
52
Laravel 教程
1333
25
PHP教程
1278
29
C# 教程
1257
24
AI模擬器拿下實體模擬新SOTA! AI模擬器拿下實體模擬新SOTA! Feb 19, 2024 pm 06:50 PM

機器學習讓電腦繪圖(CG)模擬更真實了!方法名為神經流向圖(NeuralFlowMaps,NFM),四個渦旋的煙霧也能精確模擬的那種:更為複雜的也能輕鬆實現:要知道,在這個AI應用滿天飛的時代,CG物理仿真仍然是傳統數值演算法的天下。 △NFM模擬「蛙跳」儘管神經網路應用在CG能創造目眩神迷的視覺效果,它卻無法嚴格、魯棒地描述物理性質。 △NFM模擬「墨滴」也正是因此,基於神經網路的物理模擬至今仍處於概念驗證(proofofconcept)的階段,所產生的效果也遠非SOTA。為了解決這個複雜問題,

如何用PHP的round()函數除以四捨五入 如何用PHP的round()函數除以四捨五入 Mar 21, 2023 pm 04:32 PM

round() 函數是PHP數字格式化函式庫中一個非常實用的函數,可以將浮點數四捨五入到指定的小數位數。但是,由於PHP的除法運算可能會出現無限小數或精度遺失的問題,因此對除數進行四捨五入也很必要。接下來,我們會詳細講解如何使用PHP的round()函數進行除以四捨五入。

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

在php中,round的意思為“四捨五入”,是一個內建函數,作用是將浮點數轉換為整數;該函數可以對浮點數進行四捨五入,並返回一個float類型的整數值,語法“round(number, precision,mode);」。

把Transformer當通用計算機用,還能執行in-context learning演算法,這項研究腦洞大開 把Transformer當通用計算機用,還能執行in-context learning演算法,這項研究腦洞大開 Apr 13, 2023 am 11:31 AM

Transformer 已成為各種機器學習任務的熱門選擇,並且取得了很好的效果,那它還能怎麼用?腦洞大開的研究者竟然想用它來設計可程式計算機!這篇論文的作者來自普林斯頓大學和威斯康辛大學,標題為《Looped Transformers as Programmable Computers》,旨在探索如何用 Transformer 來實現通用電腦。具體來說,作者提出了一個將 transformer 網路用作通用電腦的框架,方法是使用特定權重對它們進行程式設計並將它們置於循環(loop)中。在這個框架

三星收購英國知識圖譜新創公司 本地 AI 模擬人類思考方式處理任務 三星收購英國知識圖譜新創公司 本地 AI 模擬人類思考方式處理任務 Jul 19, 2024 pm 12:44 PM

近日,三星公司宣布收購英國知識圖譜新創公司OxfordSemanticTechnologies,增強其本地AI功能,為用戶提供更個人化的AI體驗。該公司主要產品是AI引擎RDFox,透過知識圖譜技術,將資訊儲存為網路絡,處理資料的方式類似於人類的思考方式:獲取、記憶、回憶和推理知識。這項技術將增強設備對使用者使用產品或服務的理解,從而實現快速資訊檢索和推薦。據了解,OxfordSemanticTechnologies成立於2017年,由三位牛津大學教授伊恩·霍羅克斯、鮑里斯·莫蒂克和貝爾納多·昆卡

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

MySQL中如何使用ROUND函數截取小數位數在MySQL中,可以使用ROUND函數來截取小數的位數。 ROUND函數可以把一個數字四捨五入到指定的小數位數。以下將為您詳細介紹ROUND函數的使用方法,並提供程式碼範例。語法:ROUND(X,D)X表示要四捨五入的數字,D表示要保留的小數位數。使用ROUND函數截取小數位數的範例:假設有一個表格名為produc

如何在 Golang 中使用隨機數進行模擬? 如何在 Golang 中使用隨機數進行模擬? Jun 06, 2024 pm 01:16 PM

使用math/rand套件進行隨機數模擬:導入math/rand包。使用time.Now().UnixNano()初始化隨機數產生器。使用rand.Intn(n)產生0到n-1之間的隨機整數。使用rand.Float64()產生0到1之間的浮點數。

如何利用GitLab進行API測試與模擬 如何利用GitLab進行API測試與模擬 Oct 27, 2023 pm 05:35 PM

如何利用GitLab進行API測試和模擬引言:在進行軟體開發過程中,API(ApplicationProgrammingInterface,應用程式介面)測試和模擬是非常重要的一步,它可以幫助開發人員驗證API的正確性和效能,並且可以提前發現潛在的問題。 GitLab是一個非常受歡迎的程式碼託管平台,實現了版本控制和團隊協作等功能。本文將介紹如何運用Git

See all articles