結果
問題 | No.2577 Simple Permutation Guess |
ユーザー |
|
提出日時 | 2023-12-09 01:02:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 686 ms / 2,000 ms |
コード長 | 770 bytes |
コンパイル時間 | 161 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 94,792 KB |
平均クエリ数 | 248.84 |
最終ジャッジ日時 | 2024-09-27 03:23:35 |
合計ジャッジ時間 | 35,580 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 108 TLE * 3 |
ソースコード
def solve(): n=int(input()) fact=[] def go(pos): arr=[] for i in range(1,n+1): arr.append(i) for i in range(n,0,-1): val=arr[pos//fact[i-1]] arr.pop(pos//fact[i-1]) pos=pos%fact[i-1] print(val,end=' ') print() def getans(pos): print("!",end=' ') go(pos) exit(0) def check(pos): print("?",end=' ') go(pos) ans=int(input()) return (ans==1) fact.append(1) ls=1 for i in range(1,500): ls*=i fact.append(ls) low=0 up=fact[n] while(up-low>1): mid=(low+up)//2 if(check(mid)): low=mid else: up=mid getans(low) solve()