28362023-01-29 14:44:31VMGoJoNomekoppython3Time limit exceeded 0/10017ms6204 KiB
from sys import stdin, stdout
def main():
    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)
main()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Time limit exceeded16ms3784 KiB
subtask20/10
2Time limit exceeded14ms3980 KiB
3Time limit exceeded14ms4068 KiB
subtask30/30
4Time limit exceeded14ms4256 KiB
5Time limit exceeded16ms4532 KiB
6Time limit exceeded14ms4744 KiB
7Time limit exceeded16ms4632 KiB
8Time limit exceeded14ms4748 KiB
9Time limit exceeded16ms4832 KiB
subtask40/20
10Time limit exceeded16ms4940 KiB
11Time limit exceeded16ms4868 KiB
12Time limit exceeded16ms5060 KiB
13Time limit exceeded16ms5208 KiB
subtask50/40
14Time limit exceeded17ms5464 KiB
15Time limit exceeded17ms5528 KiB
16Time limit exceeded17ms5472 KiB
17Time limit exceeded17ms5412 KiB
18Time limit exceeded17ms5724 KiB
19Time limit exceeded17ms5808 KiB
20Time limit exceeded17ms5880 KiB
21Time limit exceeded17ms6204 KiB