Jack and Jill
Jack and Jill went up the hill Swapping neighbour numbers. With n at 11 and k at 7, Jack felt unencumbered.
To his dismay, Jill did play, A rather cunning game. One by one, the numbers come, With victory there to claim
Next came 1, the game not done And with that the air had tensed. With Jack to play, 10 he did say But their difference, too immense!
Jack and Jill are climbing up a hill, and to pass the time they are playing a game of neighbour numbers. In the game, they start by picking two values, and . The game then consists of them taking turns saying numbers from to .
There are only two rules in neighbour numbers:
- No number can be repeated
- For the th turn, that number must have a distance of or less from the th number.
In this problem, we are Jill, and we'll simply be implementing a player for the game of neighbour numbers. We don't need to win, just not to make any illegal moves.
Interaction
This problem is interactive, which means you will need to collect input and print output multiple times.
The interaction will start with a line containing two space-separated integers, and . Next, you should output a single integer, your first move in the game. Each time you print an integer, the judge will then respond with another integer.
You should interact in one of three possible ways:
- If their move was invalid, print "I win!", and the program ends.
- If you have no possible move, "You win!", and the program ends.
- Otherwise, print a valid integer response, and interaction continues.
Interaction Examples
Example 1: Jack (judge) prints an invalid answer
[Jack]: 5 2
[Jill]: 3
[Jack]: 1
[Jill]: 2
[Jack]: 5
[Jill]: I win!
This is invalid because 5 and 2 are distance 3 () distance apart.
Example 2: Jill has no response
[Jack]: 10 1
[Jill]: 2
[Jack]: 1
[Jill]: You win!
Interaction Template (Python)
# Alternatively, this can be done with
# n, k = list(map(int, input().split()))
n_str, k_str = input().split()
n, k = int(n_str), int(k_str)
first_num = ...
# Jill's first number
print(first_num)
# Judge's first number
judge_response = int(input())
# Jill's response
print(...)
Constraints
- Every integer answer from Jack will be a number from to .
Comments