Secret Sequence
시간 제한1초메모리 제한1024 MB
두 구간의 합을 비교하는 질의를 200번 이하로 사용해, 숨겨진 0과 1 수열에 들어 있는 1의 개수를 구한다.
문제
There is a secret sequence of zeros and ones of length , and you want to know the number of ones in the sequence. You are allowed to ask queries by giving four integers . The answer to the query will be if the sum of the numbers at positions is larger than the sum of the numbers at positions , and if the sum is smaller. If the sums are equal, the answer will be .
The indices of the sequence start at and end at . Note that the intervals you're querying can be empty, if or respectively. The sum of the numbers in an empty interval is .
Figure out the total number of ones in the sequence using at most queries.