(简单)搜索 HOJ 1692 Choose Your Own Adventure
来源:互联网 发布:radan软件 编辑:程序博客网 时间:2024/06/04 18:41
Choose Your Own Adventure
Submitted : 52, Accepted : 29
After reading the book Tim and Marc Kill Kenny about fifty zillion times, James decided he'd had it with choose-your-own-adventure stories. No matter what choices he made, it seemed like Kenny always fell down an abandoned mine shaft, got run over by a bus load of nuns, or was messily devoured by stray cats. James eventually found the page with the happy ending (where Kenny saves himself by trapping Tim and Marc between the pizza and the hungry programmers) by flipping through the book, but he can't figure out how to get there by following the rules. Luckily, he owns a C compiler...
Input
Input to this problem will consist of a (non-empty) series of up to 100 data sets, each representing a choose-your-own-adventure story. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets.
The first line contains a single integer n indicating the number of data sets.
A single data set has 2 components:
- Page Count - A line containing a single integer X, where 1 < X < 100, indicating the number of pages in the story.
- Page List - A sequence of X lines, each of which represents a page from the book. Each line has the following components separated from one another by single spaces:
- Line type - A single character indicating what type of line this is. It will represent either a "C" choice page, or an "E" end page. Page 1 is always a choice page.
- Text - A string of text surrounded by double quotes. Including the quotes, this component will not exceed 256 characters. The quotes are given for input purposes only and should not be considered part of the text. The text will not contain embedded double quotes.
- Choices - Two positive integers from 1 to X indicating the pages where the reader can go from this page. Only choice pages have this component.
- Ending Type - Either the text "HAPPY" or "GRISLY". There will only be one happy ending per story, and only end pages have this component.
Output
For each story in the input:
- Output a single line, "STORY #" where # is 1 for the first story, 2 for the second story, etc.
- Determine the story that begins on page 1 and ends on the happy ending page. Output the text of this story, printing one "page" of text per line. Note that there is only one such story for each data set.
Sample Input
23C "Arrived at LSU for the contest" 2 3E "Was devoured by sidewalk ants" GRISLYE "Won the contest. Received glory and nachos." HAPPY5C "Saw a peanut" 3 5E "Made peanut butter sandwich" HAPPYC "Found a hammer" 4 2E "Hit self on head with hammer, ouch!" GRISLYE "Ate the peanut, choked on it, and died" GRISLYSample Output
STORY 1Arrived at LSU for the contestWon the contest. Received glory and nachos.STORY 2Saw a peanutFound a hammerMade peanut butter sandwich
- (简单)搜索 HOJ 1692 Choose Your Own Adventure
- 搜索 HOJ 1692 Choose Your Own Adventure
- poj 2023 Choose Your Own Adventure 树形结构的搜索
- poj 2023 Choose Your Own Adventure
- Poj 2023 Choose Your Own Adventure
- poj 2023 Choose Your Own Adventure 用队列广搜 用栈深搜 用递归深搜 三种方法均测试过
- Make Your Own Python Text Adventure.pdf 英文原版 免费下载
- (简单)搜索 HOJ 1022 Spacecraft Malfunction
- (简单)搜索 HOJ 1030 Labyrinth
- (简单) 搜索 HOJ 1044 Transportation
- (简单) 搜索 HOJ 1048 Cipher
- (简单)搜索 HOJ 1070 Word
- (简单)搜索 HOJ 1075 The Castle
- Hoj 1307 Choose Your Words Carefully、Hoj 1989 The Most Frequent Word
- (简单) 搜索 HOJ 1066 Substrings
- (简单) 搜索 HOJ 1097 Robot
- BYOD(Bring Your Own Device)
- hdu 4158 hoj 2581 Go 简单搜索
- (中等) 背包 HOJ 1293 Prison Rearrangement
- (中等) 动态规划+搜索 HOJ 2156 Colored stones
- openstack实时迁移
- 搜索 HOJ 1114 Frame Stacking
- 基础题 HOJ 1140 Expanding Fractions
- (简单)搜索 HOJ 1692 Choose Your Own Adventure
- Gentoo无线网卡安装之b43无线驱动篇(二)
- (博弈) HOJ 2939 Coin Question
- 搜索 HOJ 1749 Doggone Moles
- 搜索(水) HOJ 1870 Race
- 概率dp POJ 2096 Collecting Bugs
- 概率dp HDU 4089 Activation
- (概率+树形)dp HDU 4035 Maze
- 概率dp HDU 4336 Card Collector
程序博客网,程序员的互联网技术博客家园。csdn论坛精品 msdn技术资料都在这里