This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import sys
n,q = map(int, input().split())
a = []
sussies = [0 for i in range(n+1)]
for i in range(1, n+1):
if len(a)==0:
a.append(i)
continue
print("?",a[-1],i),sys.stdout.flush()
if int(input()):
sussies[a.pop()-1] = 1
sussies[i-1] = 0
else:
a.append(i)
print("! ",end="")
for i in range(n):
print("(" if sussies[i] else ")", end="")
# | 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... |