Logo
(追記) (追記ここまで)

12413번 - Technology Planning (Small1) 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB38332485.714%

문제

You are playing a culture simulation game, in which your culture can develop various technologies. Some technologies depend upon others; if technology A depends upon technology B, you cannot develop B until you have developed A. Your culture can work on only one technology at a time.

In the game, you have goals which require particular technologies. You have decided to write a program to help you by planning out the order in which to develop technologies.

입력

The input to your program starts with the number of test cases, T, on a line by itself. T test cases follow. Each one consists of:

  • One line with an integer, M, which is the number of technological dependencies.
  • M lines, each one containing two technology names, separated by a colon (':'). The first technology depends on the second one.
  • One line with an integer, Q, which is the number of goal technologies.
  • Q lines, each naming a goal technology.

Each technology name is a sequence of alphanumeric characters (letters or numbers). Technology names are case-sensitive.

Limits

  • T ≤ 25
  • M ≥ 1
  • Q ≥ 1
  • There will be no cycles in the dependency graph.
  • M ≤ 10
  • Q ≤ 10.

출력

The output for each case should start with a line of the form "Case #C: D", where C is the case number, starting from 1, and D is the smallest possible number of technologies that have to be researched. The next D lines should each contain one technology, in the order that they need to be researched.

If there are several possible correct orderings, any one of them is acceptable.

제한

예제 입력 1

4
9
Metalworking:Fire
Pottery:Fire
Iron:Metalworking
Steel:Iron
Battleships:Steel
Alchemy:Fire
Chemistry:Alchemy
Explosives:Chemistry
Battleships:Explosives
1
Battleships
9
Metalworking:Fire
Pottery:Fire
Iron:Metalworking
Steel:Iron
Battleships:Steel
Alchemy:Fire
Chemistry:Alchemy
Explosives:Chemistry
Battleships:Explosives
2
Metalworking
Pottery
2
b:a
c:b
1
d
1
A:a
1
A

예제 출력 1

Case #1: 8
Fire
Metalworking
Iron
Steel
Alchemy
Chemistry
Explosives
Battleships
Case #2: 3
Fire
Pottery
Metalworking
Case #3: 1
d
Case #4: 2
a
A

힌트

출처

Contest > Google > Google's Coding Competitions > EuroPython 2012 > EuroPython 2012 D1번

  • 스페셜 저지를 만든 사람: isku

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /