結果

問題 No.282 おもりと天秤(2)
ユーザー rpy3cpprpy3cpp
提出日時 2015-09-19 00:43:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,264 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 11,032 KB
実行使用メモリ 24,832 KB
平均クエリ数 329.00
最終ジャッジ日時 2023-09-23 06:14:12
合計ジャッジ時間 29,178 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
23,976 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 39 ms
24,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
N = int(input())

def solve(N):
    dp = [0] * N
    for d in range(1, N):
        for shift in range(2):
            q = make_query(shift, d, N)
            if not q:
                continue
            query = '? ' + ' '.join(map(str, q))
            print(query)
            sys.stdout.flush()
            reply = input()
            analyze(reply, q, dp)
    answer = get_answer(dp)
    print('! ' + ' '.join(map(str, answer)))
    sys.stdout.flush()


def make_query(shift, d, N):
    used = [False] * N
    q = []
    for idx in range(shift*d, N):
        if used[idx]:
            continue
        idx2 = idx + d
        if idx2 >= N:
            break
        q.extend([idx + 1, idx2 + 1])
        used[idx] = True
        used[idx2] = True
    if not q:
        return q
    n_blank = 2 * N - len(q)
    q.extend([0] * n_blank)
    return q


def analyze(reply, q, dp):
    idx = 0
    for r in reply:
        left, right = q[idx], q[idx + 1]
        idx += 2
        if left == 0:
            return
        if r == '>':
            dp[left - 1] += 1
        if r == '<':
            dp[right - 1] += 1
            

def get_answer(dp):
    answer = [0] * N
    for i, w in enumerate(dp, 1):
        answer[w] = i
    return answer


solve(N)
0