結果
| 問題 |
No.5008 [Cherry Alpha] Discrete Pendulum with Air Resistance
|
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2022-08-01 20:58:14 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 3,647 bytes |
| コンパイル時間 | 251 ms |
| 実行使用メモリ | 88,640 KB |
| スコア | 0 |
| 最終ジャッジ日時 | 2022-10-14 21:10:59 |
| 合計ジャッジ時間 | 20,075 ms |
|
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 50 |
ソースコード
"""
作戦 0: 等差数列で写真を取る
作戦 1: 上位 L 枚を採用
作戦 2: 山登り
作戦 3: アニーリング
作戦 4: 初期解を頑張る.
作戦 5: 作戦 4 の下でアニーリング
作戦 6: ビームサーチ
"""
#==================================================
# 関数部
def debug(*message):
print(*message,file=sys.stderr)
def General_Binary_Increase_Search_Integer(L, R, cond, default=None):
""" 条件式が単調増加であるとき, 整数上で二部探索を行う.
L: 解の下限
R: 解の上限
cond: 条件(1変数関数, 広義単調増加を満たす)
default: Lで条件を満たさないときの返り値
"""
if not(cond(R)):
return default
if cond(L):
return L
R+=1
while R-L>1:
C=L+(R-L)//2
if cond(C):
R=C
else:
L=C
return R
def move(start,direction,time):
return start+direction*time
def position(i,T):
if T<B[i]:
return T
T-=B[i]
if T<F[i]:
check=lambda p:T<2*p*B[i]-p*p*E[i]
p=General_Binary_Increase_Search_Integer(1,H[i],check,None)
direction=pow(-1,p)
start=pow(-1,p-1)*(B[i]-(p-1)*E[i])
return move(start,direction,T-(2*(p-1)*B[i]-pow(p-1,2)*E[i]))
T-=F[i]
if T<(B[i]-H[i]*E[i])+M[i]:
direction=pow(-1,H[i]+1)
start=pow(-1,H[i])*(B[i]-H[i]*E[i])
return move(start,direction,T)
if M[i]>0:
T-=(B[i]-H[i]*E[i])+M[i]
q,r=divmod(T,2*M[i])
direction=pow(-1,H[i]+2+q)
start=pow(-1,H[i]+1+q)*M[i]
return move(start,direction,r)
else:
return 0
def PROBABILITY(delta,temp):
if delta>=0:
return 1
else:
return exp(delta/temp)
Memo={}
def picture(t):
if t in Memo:
return Memo[t]
X=[position(i,t) for i in range(N)]
score=0
for i in range(N):
for j in range(i+1,N):
score+=abs(X[i]-X[j])/(B[i]+B[j])
score*=pow(10,9)*(2/(N*(N-1)))
Memo[t]=round(score)
return Memo[t]
#==================================================
# インポート
from operator import itemgetter
from time import *
from heapq import *
from random import *
from math import *
import sys
#==================================================
# 入力
N,L,Delta=map(int,input().split())
B=[0]*N; M=[0]*N; E=[0]*N
for i in range(N):
B[i],M[i],E[i]=map(int,input().split())
#==================================================
H=[0]*N; F=[0]*N
for i in range(N):
H[i]=(B[i]-M[i])//E[i]
F[i]=2*B[i]*H[i]-E[i]*H[i]*H[i]
#==================================================
BEGIN_TIME=time()
TIME_LIMIT=1.800
TEMPERATURE=5
ALPHA=0.999
BEAM_SIZE=20
TIME_DELTA=5
#==================================================
A=[]
X=[(picture(t),t) for t in range(Delta, Delta+BEAM_SIZE)]
while time()-BEGIN_TIME<TIME_LIMIT:
S=set()
Y=[]
for _,t in X:
for u in range(t+Delta,t+Delta+TIME_DELTA):
if u not in S:
S.add(u)
Y.append((picture(u),u))
Y.sort(key=itemgetter(0),reverse=True); Y=Y[:BEAM_SIZE]
A+=Y
X=Y
#==================================================
A.sort(key=itemgetter(0),reverse=True)
T=[]
for _,u in A:
flag=1
for t in T:
flag&=abs(t-u)>=Delta
if flag:
T.append(u)
if len(T)==L:
break
#==================================================
T.sort()
print(len(T))
print(*T)
Kazun