Vacant Seat
시간 제한2초메모리 제한256 MB
남녀가 번갈아 앉은 홀수 크기 원형 좌석에서 성별만 알려주는 질의를 20번 이하로 보내 빈 좌석 하나를 찾는다.
문제
Let be an odd number.
There are seats arranged in a circle. The seats are numbered through . For each (), seat and seat are adjacent. Also, seat and seat are adjacent.
Each seat is either vacant, or occupied by a man or a woman. However, no two adjacent seats are occupied by two people of the same sex. It can be shown that there is at least one empty seat because is an odd number greater than .
You are given , but the states of the seats are not given. Your objective is to correctly guess the ID number of any one of the empty seats. To do so, you can repeatedly send the following query:
Choose an integer (). If Seat is empty, the problem is solved. Otherwise, you are notified of the sex of the person at seat .
Guess the ID number of an empty seat by sending at most queries.
힌트
In the sample, , and Seat , , are occupied by a man, occupied by a woman and vacant, respectively.