結果
問題 | No.2577 Simple Permutation Guess |
ユーザー |
![]() |
提出日時 | 2023-12-05 00:24:42 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 531 bytes |
コンパイル時間 | 200 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 41,300 KB |
平均クエリ数 | 30.44 |
最終ジャッジ日時 | 2024-09-26 23:38:13 |
合計ジャッジ時間 | 7,308 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 90 TLE * 21 |
ソースコード
import sys import math N=int(input()) fact = [1] for i in range(1,501): fact.append(fact[-1]*i) def get(v): alive = [1]*N ret = [] for i in range(N,0,-1): x = v // fact[i-1] + 1 v %= fact[i-1] for a in range(N): if alive[a]==1: x -= 1 if x==0: alive[a]=0 ret.append(str(a+1)) break assert len(ret)==N return ret L=0 R=fact[N] while L+1<R: M=(L+R)//2 arr = get(M) print("? "+" ".join(arr)) ret=int(input()) if ret==1: L=M else: R=M arr = get(L) print("! "+" ".join(arr))