28342023-01-29 11:19:25VMGoJoNomekoppython3Time limit exceeded 0/10017ms7180 KiB
from sys import stdin, stdout

n:int=int(stdin.readline())
powers=stdin.readline().split()
powers = [int(i) for i in powers]

def test_setup(p_in:list[int]) ->int:
    stdout.write("? "+" ".join(map(str, p_in)))
    stdout.flush()
    return int(stdin.readline())

a=powers[0]
b=powers[1]
diffs:list[int]=[0]
l=test_setup(powers)
for i in range(1,n):
    #SWAP
    b=powers[i]
    new_setup=powers.copy()
    new_setup[0],new_setup[i]=powers[i],powers[0]
    
    k=test_setup(new_setup)
    diffs.append((l-k)/(a-b))

powers_sorted:list[int]=powers.copy()
powers_sorted.sort()
final_setup:list[int]=[]
print(diffs)
for i in range(len(diffs.copy())):
    loc_found:int
    szelsoertek:int=-1000000000000000000000000000
    for j in range(len(diffs)):
        if diffs[j]>szelsoertek:
            loc_found=j
            szelsoertek=diffs[j]
            #print("temp found "+str(diffs[j]))
    #print("found "+str(diffs[loc_found]))
    diffs.pop(loc_found)
    final_setup.append(powers_sorted.pop(loc_found))
#WRITE FINAL
stdout.write("! "+" ".join(map(str, final_setup)))
stdout.flush()
exit(0)
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Time limit exceeded16ms3704 KiB
subtask20/10
2Time limit exceeded16ms3968 KiB
3Time limit exceeded16ms4200 KiB
subtask30/30
4Time limit exceeded16ms4480 KiB
5Time limit exceeded16ms4760 KiB
6Time limit exceeded16ms4776 KiB
7Time limit exceeded16ms4996 KiB
8Time limit exceeded16ms5144 KiB
9Time limit exceeded16ms5488 KiB
subtask40/20
10Time limit exceeded16ms5384 KiB
11Time limit exceeded16ms5592 KiB
12Time limit exceeded16ms5784 KiB
13Time limit exceeded16ms6020 KiB
subtask50/40
14Time limit exceeded17ms6588 KiB
15Time limit exceeded17ms6684 KiB
16Time limit exceeded17ms6808 KiB
17Time limit exceeded17ms6724 KiB
18Time limit exceeded17ms6892 KiB
19Time limit exceeded17ms7180 KiB
20Time limit exceeded17ms7136 KiB
21Time limit exceeded17ms6988 KiB