Codeforces Round #256 (Div. 2) B. Suffix Structures(模拟)_html/css_WEB-ITnose
题目链接: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>

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

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

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

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

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

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

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

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

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

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

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