Mysterious Tree
시간 제한1초메모리 제한2048 MB
꼭짓점 n개짜리 숨겨진 트리가 사슬인지 별인지 간선 질문을 ceil(n/2)+3번 이하로 던져 판별한다.
문제
This is an interactive problem.
Randias has an unknown hidden tree with vertices. The tree is either a chain or a star. Randias now needs to determine whether the tree is a chain or a star. He can ask a question in the following form, but no more than times:
- Is there an edge between vertex and vertex (, )?
Randias needs to determine which of the two kinds the tree is. Help him to ask the questions and determine the answer.
A tree is called a chain if and only if there exists a permutation such that, for every (), there is an edge in the tree. Here, a permutation of length is an array where each integer from to appears exactly once.
A tree is called a star if and only if there exists a vertex such that, for every other vertex , there is an edge in the tree.
In this problem, the interactor is adaptive, which means that the secret tree is not fixed beforehand. Instead, the interactor can change the tree arbitrarily during the interaction. Nevertheless, at every moment, the tree will be consistent with all the answers you got.
입력
Each test contains multiple test cases. The first line contains a single integer () denoting the number of test cases.
For each test case, the first line contains one integer () denoting the number of vertices. It is guaranteed that the sum of over all test cases does not exceed .