编程介的小学生 2019-05-03 17:57 采纳率: 20.5%
浏览 221

C语言解决字符的序列的输出的问题,具体的程序的编写的实现的做法怎么实现?

Problem Description
So many towns are in drought! The mayor is anxious!
Luckily, There is a reservoir on the mountain top, and the mayor wants to use the water there to irrigate the farmland. The only way is to build some NEW channels to connect the towns that in drought to the reservoir directly or indirectly. Now the problem is the mayor wants to konw what is the least number of channels that have to build to connect all the towns in drought to the reservoir directly or indirectly.

Input
The input consists of multiple test cases. Each case begins with a line containing a positive integer n(0 <= n <= 100), following n pairs of towns in the form "A B", means there has been a channel from A to B. The third line contains a positive integer m(0 <= m <= 16), following m lines containing the names of those towns in drought. The last line contains a town's name which the reservoir is in. You should note that the names of the towns only contain 'A' to 'Z',and their length will less than 100.

Output
For each test case, output one line containing the minimum number of channels you have to built.

Sample Input
2
A B
B C
2
B
C
A
1
A B
2
B
C
A

Sample Output
0
1

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 本题的答案是不是有问题
    • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
    • ¥15 C++使用Gunplot
    • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
    • ¥15 matlab数字图像处理频率域滤波
    • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
    • ¥15 ELGamal和paillier计算效率谁快?
    • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
    • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
    • ¥15 Arcgis相交分析无法绘制一个或多个图形