Hora
시간 제한1초메모리 제한2048 MB
원형 구간에 있는 남학생 수를 묻는 질의를 이용해, 남학생과 여학생 수의 차이가 가장 작은 길이 K의 원형 구간을 찾는다.
문제
This is an interactive problem!
Hora is a traditional Romanian and Moldovan folk dance in which participants join hands and form a large circle...
At the 8th European Junior Olympiad in Informatics, participants started dancing hora, where is a positive, even integer. The number of boys is equal to the number of girls. The organizers assigned a circular index to every participant in the hora. The indexes start from and continue consecutively in increments of , up to . This means that participants with indexes and are neighbors, and that each participant’s index is one greater than that of their previous neighbor. Please refer to the Examples section for visualizing such a configuration.
You don't know exactly which participants are girls and which participants are boys, since you are participating in the competition right now! However, you can make calls to the testing system. Each call consists of two integers and such that and . The response will contain an integer - the number of boys on the continuous circular interval from to in our circle. In particular:
- If , then the answer will consider the continuous circular interval of participants with indexes .
- If , then the answer will consider the continuous circular interval of participants with indexes .
You are given an integer (). Your task is to find a continuous circular interval of length in our circle for which the absolute difference between the number of boys and girls is as small as possible. More formally, you are asked to implement a procedure that returns an integer () such that a continuous circular interval of length starting from has the smallest absolute difference between the number of boys and the number of girls among all the possible continuous circular intervals of length . Note that a certain circle configuration may have multiple solutions with the same smallest absolute difference between the number of boys and girls. In such a case, you may return any of them.
The absolute difference between two numbers and is given by . For example, , .
제한
- is even.
- The hora has an equal number of participating boys and girls.
- The grader is not adaptive.
예제
이 문제는 공개된 예제가 없습니다.