编程介的小学生 2017-08-08 08:53 采纳率: 20.5%
浏览 724
已采纳

Efficient Codes

In the C programming language, the programmers are allowed to include header files (.h files) into their source files (.c files). For example, in a source file "example.c" you may write like this:

#include "header_0.h"
#include "header_1.h"
#include
...

int main()
{
...
}
However, in some cases the header files themselves may include one another. For example, in the above example the header file "header_1.h" may have already included "stdio.h". In that case, "header_1.h" may look like this:

#include
#include
...

void function1();
...
So after all, you just have to include "header_0.h" and "header_1.h" in your "example.c". Although it is usually harmless if you actually have included a header file several times in your source file, you just want to eliminate those useless codes to make your code as short as possible. Therefore, you decide to write a program to do this task.

Input

The input contains multiple test cases!

Each case begins with a number N (1 <= N <= 100) indicating the number of header files included by a source file. Then the descriptions of header files are given. For each file, the description consists of two lines. On the first line, the name of that file is given. The second line starts with a number M, followed by M strings which represent the name of files included by the given one. File names will contain only lower case letters ('a'..'z'), number characters ('0'..'9'), the underscore character ('_') or the dot character ('.'). The length of each file name is between 3 and 20 and the number of characters in a line never exceeds 2000. It is also assumed that there is no circular including (that is, A includes B and B also includes A, or even A includes B and B includes C and C includes A, and so on) in your files because that usually causes a compilation error.

Proceed to the End Of File(EOF).

Output

For each test case, output the minimum set of files that should be directly included by the source file. Each file name occupies a line and they should be listed in the alphabetic order.

Separate two consecutive test cases with a blank line, but Do NOT output an extra blank line after the last one.

Sample Input
3
header_0.h
0
header_1.h
1 stdio.h
stdio.h
0
2
a.h
3 b.h c.h d.h
e.h
0
Sample Output
header_0.h
header_1.h

a.h
e.h

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-08-22 15:54
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)