아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Vacant Seat

시간 제한2초메모리 제한256 MB

요약
남녀가 번갈아 앉은 홀수 크기 원형 좌석에서 성별만 알려주는 질의를 20번 이하로 보내 빈 좌석 하나를 찾는다.
난이도

보통10점 중 7점

유형
이분 탐색, 수학
정답자
아직 제출이 없습니다

문제

Let N≥3N \ge 3 be an odd number.

There are NN seats arranged in a circle. The seats are numbered 00 through N−1N-1. For each ii (0≤i≤N−20 \le i \le N - 2), seat ii and seat i+1i + 1 are adjacent. Also, seat N−1N - 1 and seat 00 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 NN is an odd number greater than 11.

You are given NN, 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 ii (0≤i≤N−10 \le i \le N - 1). If Seat ii is empty, the problem is solved. Otherwise, you are notified of the sex of the person at seat ii.

Guess the ID number of an empty seat by sending at most 2020 queries.

힌트

In the sample, N=3N = 3, and Seat 00, 11, 22 are occupied by a man, occupied by a woman and vacant, respectively.

예제1

  1. 예제 1

    입력
    3
    
    Male
    
    Female
    
    Vacant
    
    예상 출력
    
    0
    
    1
    
    2