結果
問題 | No.5020 Averaging |
ユーザー | ゆ |
提出日時 | 2024-02-25 16:09:59 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,316 bytes |
コンパイル時間 | 270 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 74,428 KB |
スコア | 12,719,802 |
最終ジャッジ日時 | 2024-02-25 16:10:05 |
合計ジャッジ時間 | 5,932 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | RE | - |
ソースコード
from time import time start = time() import sys from random import randint,sample from itertools import combinations from collections import defaultdict def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def ms(): return map(int, input().split()) def li(): return list(map(int,input().split())) # //////////////////////////////// N = ii() A = list() B = list() for i in range(N): a,b = ms() A.append(a) B.append(b) NUM = [i for i in range(2,N)] STAND = 5*pow(10,17) def create_abs(A,B,V1,V2,PREV): ABS = list() for v in range(1,N): na,nb = (A[0]+A[v])//2,(B[0]+B[v])//2 if A[0]==A[v] and B[0]==B[v]: continue if PREV[(0,v)]==(na,nb): continue n1,n2 = abs(na-STAND),abs(nb-STAND) tmp = max(V1,V2)-max(n1,n2) ABS.append((tmp,v)) ABS.sort(reverse=True) return ABS def other_merge(A,B,PREV): # STANDにできるだけ近いやつを作る CAND = list() for (u,v) in combinations(NUM,2): if A[u]==A[v] and B[u]==B[v]: continue na,nb = (A[u]+A[v])//2,(B[u]+B[v])//2 if PREV[(u,v)]==(na,nb): continue n1,n2 = abs(na-STAND),abs(nb-STAND) CAND.append((max(n1,n2),u,v)) CAND.sort() ind = randint(0,5) u,v = CAND[ind][1],CAND[ind][2] return u,v def play(A,B): global MAXV,BEST_ANS TURN = 0 ANS = list() V1,V2 = abs(A[0]-STAND),abs(B[0]-STAND) flag = False PREV = defaultdict(tuple) while TURN<50: if time()-start>0.9: return if flag: u,v = sample(NUM,2) flag = False else: ABS = create_abs(A,B,V1,V2,PREV) if ABS[0][0]==0: # 頭打ちになったら1以外とマージする u,v = sample(NUM,2) elif A[0]==A[ABS[0][1]] and B[0]==B[ABS[0][1]]: u,v = sample(NUM,2) elif ABS[0][0]<0: u,v = sample(NUM,2) else: u,v = 0,ABS[0][1] flag = True ANS.append((u+1,v+1)) na,nb = (A[u]+A[v])//2,(B[u]+B[v])//2 if u==0: n1,n2 = abs(na-STAND),abs(nb-STAND) V1,V2 = n1,n2 A[u],A[v],B[u],B[v] = na,na,nb,nb PREV[(u,v)] = (na,nb) TURN += 1 if MAXV>max(V1,V2): MAXV = max(V1,V2) BEST_ANS = [a[:] for a in ANS] return BEST_ANS = list() MAXV = pow(10,18) while time()-start<0.9: AA = A[:] BB = B[:] play(AA,BB) cnt += 1 print(len(BEST_ANS)) for u,v in BEST_ANS: print(u,v)