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 random
def getAnItem(s):
for thing in s:
return thing
def test(lst):
return int(input(str(len(lst)) + " " + " ".join([str(i+1) for i in lst]) + "\n"))
def div_and_conquer(l, u):
if l == u - 1:
return [{l}]
mid = (l + u) // 2
rl = div_and_conquer(l, mid)
rr = div_and_conquer(mid, u)
used = set()
for val_in in rr:
flag = True
for key_out, val_out in enumerate(rl):
if key_out not in used and test([getAnItem(val_in), getAnItem(val_out)]) == 1:
val_out.update(val_out.union(val_in))
used.add(key_out)
flag = False
break
if flag:
rl.append(val_in)
return rl
def iterative():
dat = []
for i in range(n):
flag = True
for val in dat:
if test([i, getAnItem(val)]) == 1:
val.add(i)
flag = False
break
if flag:
dat.append({i})
return dat
if __name__ =="__main__":
n = int(input())
c = int(input(str(n) + " " + " ".join([str(i+1) for i in range(n)]) + "\n"))
div_and_conquer(0, n)
res = iterative()
toPrint = ["0"]*(n+1)
for i, s in enumerate(res):
for j in s:
toPrint[j+1] = str(i+1)
print(" ".join(toPrint))
# | 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... |