编程介的小学生 2017-03-07 11:44 采纳率: 20.5%
浏览 990
已采纳

Audubon's Stormy Arctic Trip

The program autopun assists in the creation of puns (mostly bad ones). Rather than listing every possible pun on a particular phrase it produces a rooted directed acyclic graph (DAG) as output. That is, a list of choices is given for the first word in a phrase. This choice determines not only a word but the name of another list that determines the choices for the next word, and so on. Each list is a node in the DAG, labelled with a two digit number (00 - 99).

Input

We want to find the nth pun specified by autopun. The first is simply the phrase formed by selecting the first alternative for each choice. The next is formed by selecting the next alternative for the latest choice for which an alternative remains, followed by the first alternative for all subsequent choices. That is, the order of the puns is determined by a left-to-right traversal of the leaves in the DAG.

The output of autopun consists of several node entries. The first line of an entry contains a two digit number (from 00 to 99) followed by a colon. Subsequent lines in the entry are indented and consist of 'word:node' entries separated by spaces. A '$' for a node indicates the end of the pun and 00 is the first node.

After the node entries there will be zero or more lines containing integers in the range 1 to the highest pun number for the DAG.

Subsequent test cases are separated with a single blank line. Process to the end of file.

Output

Output will consist of one pun per line with the words separated by hypens.

Sample Input

00:
silver:$ zeal:03 sill:03 shill:03 seal:03 ceil:03 Shea:02
she:02 see:02 sea:02 Sci:02 z:01 s:01 h's:01
01:
ill:03 I'll:03 ewe:03 eel:03 e:02
02:
w:03 l:03
03:
fur:$ fir:$ v:04 f:04
04:
IR:$
1
2
3
4
5
6
27

Sample Output

silver
zeal-fur
zeal-fir
zeal-v-IR
zeal-f-IR
sill-fur
Shea-l-fir

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-03-13 14:36
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退