编程介的小学生 2017-04-04 06:44 采纳率: 20.5%
浏览 853
已采纳

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-04-16 15:32
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料