(简单)搜索 HOJ 1070 Word
来源:互联网 发布:网络购票岫岩到沈阳 编辑:程序博客网 时间:2024/05/28 15:07
Word
Submitted : 114, Accepted : 46
Rewriting rules rewrite a letter at a position i, depending on letters at the positions i - 2, i, i+1. We rewrite all letters of the word in one step. When we have a given starting word and a set of rewriting rules a natural question is: how does the word look after s rewriting steps?
Help Dr. R. E. Wright and write a program which solves this task.
Input
There are several blocks in the input, each describing one system. There is an integer number n, 2 < n < 16 the length of the input word in the first line. There is a word in the next line. The word contains only lowercase letters a and b. There are four characters c1 c2 c3 c4 in the next eight lines. Each quadruple represents one rewriting rule with the following meaning: when the letter at the position i - 2 is c1 and the letter at the position i is c2 and the letter at the position i + 1 is c3 then the letter at the position i after rewriting will be c4. Rewriting rules are correct and complete. There is an integer number s, 0 <= s <= 2000000000, in the last line of the block.
Output
There is one line corresponding to each block of the input. The line contains a word which we receive after s rewriting steps from the corresponding starting word using given rewriting rules. As we mentioned above, the word can be written in any of n cyclic shifted forms. The output file contains the lexicographically smallest word, assuming that a < b.
Sample Input
5aaaaaaaabaabbabababbbbaabbabbbbabbbbb1
Sample Output
bbbbb
- (简单)搜索 HOJ 1070 Word
- (简单)搜索 HOJ 1022 Spacecraft Malfunction
- (简单)搜索 HOJ 1030 Labyrinth
- (简单) 搜索 HOJ 1044 Transportation
- (简单) 搜索 HOJ 1048 Cipher
- (简单)搜索 HOJ 1075 The Castle
- (简单) 搜索 HOJ 1066 Substrings
- (简单) 搜索 HOJ 1097 Robot
- (简单)搜索 HOJ 1692 Choose Your Own Adventure
- hdu 4158 hoj 2581 Go 简单搜索
- poj1111 hoj 1639 Image Perimeters 简单搜索
- Go hdu 4158 hoj 简单搜索
- (简单) 搜索 HOJ 1085 Finding Rectangles
- (简单) 搜索 HOJ 1105 Egyptian Multiplication
- 搜索(IDA*)HOJ The Rotation Game
- 搜索(bfs) HOJ 1448 Dungeon Master
- 搜索(水) HOJ 1870 Race
- (简单) 搜索 最短路 HOJ 1121 Erdos Numbers
- (简单) 搜索 HOJ 1044 Transportation
- (简单) 搜索 HOJ 1048 Cipher
- textview 使用自己的字体
- (中等) 搜索 HOJ 1049 sticks
- (简单) 搜索 HOJ 1066 Substrings
- (简单)搜索 HOJ 1070 Word
- (简单)搜索 HOJ 1075 The Castle
- (简单) 搜索 HOJ 1085 Finding Rectangles
- (简单) 搜索 HOJ 1097 Robot
- (中等) 线段树 HDU 3308 LCIS
- (简单) 搜索 HOJ 1105 Egyptian Multiplication
- (简单) 搜索 最短路 HOJ 1121 Erdos Numbers
- (基础) 树形dp HDU 1520 Anniversary party
- (男人八题之一)树形dp poj 1741 Tree
程序博客网,程序员的互联网技术博客家园。csdn论坛精品 msdn技术资料都在这里