結果

問題 No.282 おもりと天秤(2)
ユーザー yaoshimaxyaoshimax
提出日時 2016-05-14 02:27:50
言語 PyPy2
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,624 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 77,624 KB
実行使用メモリ 110,816 KB
平均クエリ数 223.96
最終ジャッジ日時 2023-09-23 23:52:34
合計ジャッジ時間 26,035 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
92,500 KB
testcase_01 AC 123 ms
95,208 KB
testcase_02 AC 113 ms
95,232 KB
testcase_03 AC 111 ms
94,344 KB
testcase_04 AC 102 ms
94,264 KB
testcase_05 AC 117 ms
94,900 KB
testcase_06 AC 129 ms
95,436 KB
testcase_07 AC 104 ms
94,176 KB
testcase_08 AC 126 ms
95,644 KB
testcase_09 AC 94 ms
92,764 KB
testcase_10 AC 1,447 ms
97,728 KB
testcase_11 TLE -
testcase_12 AC 1,636 ms
97,540 KB
testcase_13 AC 2,595 ms
99,276 KB
testcase_14 AC 4,625 ms
85,520 KB
testcase_15 TLE -
testcase_16 AC 333 ms
97,208 KB
testcase_17 AC 2,376 ms
99,916 KB
testcase_18 AC 4,092 ms
101,424 KB
testcase_19 AC 4,087 ms
101,916 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
N=int(raw_input())
ans=[]
ans2=[]
used=[False for i in range(N+1)]
used[0]=True

while True:
    cand = [i for i in range(N+1) if used[i]==False]
    if len(cand)==0:
        break
    elif len(cand)==1:
        ans.append(cand[0])
        used[cand[0]]=True
    elif len(cand)%2==1:
        while len(cand)>=2:
            print '?',
            for c in cand:
                print c,
            for d in range(N*2-len(cand)):
                print 0,
            print
            sys.stdout.flush()
            ncand=[]
            res=raw_input().split()
            for i in range(0,len(cand),2):
                if i==len(cand)-1:
                    ncand.append(cand[i])
                elif res[i/2]=='>':
                    ncand.append(cand[i+1])
                elif res[i/2]=='<':
                    ncand.append(cand[i])
            cand=ncand
        ans.append(cand[0])
        used[cand[0]]=True
    else:
        left=[]
        right=[]
        print '?',
        for c in cand:
            print c,
        for d in range(N*2-len(cand)):
            print 0,
        print
        sys.stdout.flush()
        ncand=[]
        res=raw_input().split()
        for i in range(0,len(cand),2):
            if res[i/2]=='>':
                left.append(cand[i+1])
                right.append(cand[i])
            if res[i/2]=='<':
                left.append(cand[i])
                right.append(cand[i+1])
        while len(left)>=2:
            nleft=[]
            nright=[]
            if len(left)%2==1:
                nleft.append(left[0])
                nright.append(right[0])
                left.pop(0)
                right.pop(0)
            print '?',
            for l in left:
                print l,
            for r in right:
                print r,
            for d in range(N*2-len(left)-len(right)):
                print 0,
            print
            sys.stdout.flush()
            res=raw_input().split()
            for i in range(len(left)/2):
                if res[i]=='>':
                    nleft.append(left[2*i+1])
                else:
                    nleft.append(left[2*i])
            for i in range(len(right)/2):
                if res[len(left)/2+i]=='>':
                    nright.append(right[2*i])
                else:
                    nright.append(right[2*i+1])
            left=nleft
            right=nright
        ans.append(left[0])
        ans2.append(right[0])
        used[left[0]]=True
        used[right[0]]=True

ans2.reverse()
ans+=ans2
print '!',
for a in ans:
    print a,
print
sys.stdout.flush()
    


            

0