結果

問題 No.282 おもりと天秤(2)
ユーザー convexineqconvexineq
提出日時 2021-02-24 05:20:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,971 ms / 5,000 ms
コード長 1,449 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 97,156 KB
平均クエリ数 221.33
最終ジャッジ日時 2023-09-24 02:52:13
合計ジャッジ時間 19,049 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
87,724 KB
testcase_01 AC 125 ms
93,248 KB
testcase_02 AC 102 ms
92,804 KB
testcase_03 AC 101 ms
92,144 KB
testcase_04 AC 102 ms
88,148 KB
testcase_05 AC 106 ms
93,384 KB
testcase_06 AC 115 ms
93,516 KB
testcase_07 AC 98 ms
88,148 KB
testcase_08 AC 116 ms
94,204 KB
testcase_09 AC 98 ms
88,176 KB
testcase_10 AC 540 ms
95,144 KB
testcase_11 AC 1,606 ms
96,616 KB
testcase_12 AC 549 ms
95,036 KB
testcase_13 AC 788 ms
95,752 KB
testcase_14 AC 1,388 ms
97,156 KB
testcase_15 AC 1,661 ms
97,076 KB
testcase_16 AC 190 ms
93,776 KB
testcase_17 AC 732 ms
95,200 KB
testcase_18 AC 1,193 ms
96,216 KB
testcase_19 AC 1,222 ms
95,544 KB
testcase_20 AC 1,786 ms
96,788 KB
testcase_21 AC 1,971 ms
96,736 KB
testcase_22 AC 1,853 ms
96,696 KB
testcase_23 AC 96 ms
88,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def ask():
    print("? " + " ".join(map(str,lst)))
    sys.stdout.flush()
    res = get() if DEBUG else input()
    return res.split()

def get():
    def f(x): return "<" if x==1 else ">" if x==-1 else "="
    #print(lst)
    res = [0]*n
    for i in range(n):
        v,w = order.index(lst[2*i]), order.index(lst[2*i+1])
        if v < w: res[i] = 1
        elif v==w: res[i] = 0
        elif v > w: res[i] = -1
    ans = " ".join(map(f,res))
    print(ans)
    return ans

import sys
n = int(input())
p = n%2
lst = [1-p,2-p]
for i in range((n+1)//2-1):
    lst += [3+i-p,n-i]
lst += [0]*(n-p)
assert len(lst) == 2*n
DEBUG = 0
order = list(range(1,n+1))
from random import shuffle
shuffle(order)
order.insert(0,0)

g = [[-5]*n for _ in range(n)]
for i in range(n+p):
    s = ask()
    # 行列に記録
    for i in range((n+p)//2):
        v,w = lst[2*i]-1,lst[2*i+1]-1
        if v==-1 or w==-1: continue
        if s[i] != "=":
            g[v][w] = 1 if s[i] == ">" else -1
            g[w][v] = 1 if s[i] == "<" else -1
        else:
            g[v][w] = g[w][v] = 1
    # サイクリックに移動        
    for j in range(1,n+p):
        lst[j] += 1
        if lst[j] > n: lst[j] = 2-p

#print(g)
ans = list(range(n))[::-1]
for i in range(n):
    for j in range(n-1-i):
        if g[ans[j]][ans[j+1]] == 1:
            ans[j],ans[j+1] = ans[j+1],ans[j]
for i in range(n): ans[i] += 1
#print(order)
print("! " + " ".join(map(str,ans)))
0