Space Thief
시간 제한2초메모리 제한2048 MB
연결된 무향 그래프에서 각 간선의 방향을 정해 도달 가능성을 묻는 질문을 300번 이내로 던져, 열쇠가 숨겨진 별 A와 보물 상자가 숨겨진 별 B를 알아낸다.
문제
You are active as a thief in JOI galaxy.
There are stars numbered from to in JOI galaxy. There are warp devices numbered from to in JOI galaxy. The warp device () connects star and star bidirectionally. It is possible to travel from any star to any star by using warp devices.
A key is hidden in a certain star, and a treasure box is hidden in another certain star. Your mission is to specify numbers, the number of the star in which the key is hidden and in which the treasure box is hidden. To achieve your mission, you can ask questions up to times as below.
-
Orient each warp device. Specifically, for each warp device (), choose one of the following:
- Allow travel only from star to star .
- Allow travel only from star to star .
-
Under these conditions, ask whether it is possible to travel from the star in which the key is hidden to the star in which the treasure box is hidden by using warp devices.
You want to specify numbers, the number of the star in which the key is hidden and the star in which the treasure box is hidden. To achieve a higher evaluation, you want to reduce the number of questions asked.
Given information about the galaxy, write a program that determines the star in which the key is hidden and the star in which the treasure box is hidden, by asking questions.
제한
All the input data satisfy the following conditions.
- .
- .
- .
- .
- .
- ().
- ().
- It is possible to travel from any star to any star by using warp devices.
예제
이 문제는 공개된 예제가 없습니다.