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

18085번 - Firetrucks Are Red 스페셜 저지다국어

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

문제

Lily is fascinated by numbers. She believes the whole world revolves around them, and that everything is connected by numbers. Her friends, Alice, Bob, Charlie and Diane, are not convinced. But she gives them an example:

Alice lives in house number 25 on her street, but that is exactly Bob’s age. Bob is born on June 4th, and Charlie was his parents’ fourth child. Finally, Diane has five fingers on her left hand, which happens to be the same as the number of toes that Bob has on his right foot!

This shows that her friends are all connected—either directly or indirectly—by numbers. But she still has to convince her family as well as her coworkers.

Given a group of n individuals, and a set of numbers that describe each individual, help Lily come up with a proof that shows that everyone in this group is either directly or indirectly connected by numbers, or determine that this is not possible.

입력

The input consists of:

  • One line with an integer n (2 ≤ n ≤ 2 · 105), the number of individuals in the group. The individuals are numbered from 1 to n.
  • n lines, describing the individuals in the group. The ith such line starts with an integer mi (1 ≤ mi ≤ 2 · 105), the number of numbers that describe individual i. The remainder of the line has mi distinct integers di,1, . . . , di,mi (1 ≤ di,j ≤ 109 for each j), the set of numbers that describe individual i.

It is guaranteed that the sum over all mi is at most 2 · 105.

출력

Output a proof in the form of n − 1 lines, each of which contains three integers p, q and r, where p and q are distinct individuals that are both described by the number r. Using only these relations, it must be possible to show that any pair of individuals in the group are connected either directly or indirectly.

If no such proof exists, output “impossible”. If there are multiple proofs, you may output any one of them.

제한

예제 입력 1

6
2 17 10
1 5
2 10 22
3 17 22 9
2 17 8
3 9 22 16

예제 출력 1

impossible

예제 입력 2

6
2 17 10
2 5 10
2 10 22
3 17 22 9
2 17 8
3 9 22 16

예제 출력 2

1 3 10
2 3 10
3 4 22
4 5 17
4 6 9

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > NWERC 2019 F번

  • 문제를 만든 사람: Bjarki Ágúst Guðmundsson
(追記) (追記ここまで)

출처

대학교 대회

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

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