Created
March 30, 2018 20:08
-
-
Save nyx-rattapoom/812cedb1f61dfb553803c53563a776cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
TOO_BIG = 'TOO_BIG' | |
CORRECT = 'CORRECT' | |
TOO_SMALL = 'TOO_SMALL' | |
WRONG_ANSWER = 'WRONG_ANSWER' | |
def main(): | |
tc = int(input()) | |
while tc: | |
tc -= 1 | |
a, b = map(int, input().split()) | |
number_list = [x for x in range(a+1, b+1)] | |
low = 0 | |
hi = len(number_list) | |
n = int(input()) | |
for i in range(n): | |
mid = (low + hi) // 2 | |
print(number_list[mid]) | |
sys.stdout.flush() | |
response = input() | |
if response == WRONG_ANSWER: | |
sys.exit(0) | |
elif response == CORRECT: | |
break | |
elif response == TOO_BIG: | |
hi = mid - 1 | |
elif response == TOO_SMALL: | |
low = mid + 1 | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment