|
||||||||||
History of LanguagesTime Limit: 2000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 843 Accepted Submission(s): 260 Problem Description We are examining two specific classes of languages (a possibly infinite set of strings) in this problem. Fortunately (or maybe unfortunately), we are not given the strings contained in each language directly, rather we are given two deterministic finite automatons that describe such languages. Your task here is simple: to determine if the languages described by the two automatons are the same. Input There are multiple test cases in the input file. The first line of each test case is one integer, T ( 2 ¡Â T ¡Â 26), the size of the alphabet. In each test case, the description of automaton A comes before that of automaton B. The description of each automaton starts with one line containing N (1 ¡Â N ¡Â 2000 ), the number of states in the automaton, followed by N lines, each line of the format: F, X0, X1, ¡¦, XT-1, ,-1 ¡Â Xi < N). If F = 1, then the state is an accepting state; also, if Xi = -1, it means that the state has no corresponding transition available for character i. The start state of both finite automatons will always be state 0. Two successive test cases are separated by a blank line. A case with a single 0 indicates the end of the input file, and should not be processed by your program. Output For each test case, please print ¡°Yes¡± if the two languages described by the automatons are equivalent; output ¡°No¡± otherwise. Sample Input
Sample Output
Source | ||||||||||
|