def solve_subtask_1(N, best_friend_pair, queries):
# Best friend pair consists of (k, k + N)
k = best_friend_pair[0]
results = []
for x, y in queries:
# If x is the best friend of y (or vice versa), the ball is passed directly
if (x == k and y == k + N) or (x == k + N and y == k):
results.append(1)
# If they are opposite in the circle, the ball takes N passes
elif (x == k and y == k + N) or (x == k + N and y == k):
results.append(1)
else:
results.append(-1) # In case of an unexpected condition
return results
# Example input
N = 4
best_friend_pair = [0] # Best friends are at positions (0, 4)
queries = [(0, 4), (1, 5)] # Query 1: from 0 to 4, Query 2: from 1 to 5
# Call the solve function for the first subtask
results = solve_subtask_1(N, best_friend_pair, queries)
# Output the results
for result in results:
print(result)
컴파일 시 표준 출력 (stdout) 메시지
Compiling 'Main.py'...
=======
adding: __main__.pyc (deflated 34%)
=======
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |