結果
| 問題 |
No.2577 Simple Permutation Guess
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-12-09 01:04:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,637 ms / 2,000 ms |
| コード長 | 958 bytes |
| コンパイル時間 | 434 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 97,216 KB |
| 平均クエリ数 | 248.84 |
| 最終ジャッジ日時 | 2024-09-27 03:24:52 |
| 合計ジャッジ時間 | 59,999 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 102 TLE * 9 |
ソースコード
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):
j=0
cur=0
while(1):
cur1=cur+fact[i-1]
if(cur1>pos):
break
else:
j+=1
cur=cur1
pos-=cur
val=arr[j]
arr.pop(j)
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()