結果
問題 | No.5007 Steiner Space Travel |
ユーザー | titan23 |
提出日時 | 2022-07-30 17:05:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 974 ms / 1,000 ms |
コード長 | 2,097 bytes |
コンパイル時間 | 246 ms |
実行使用メモリ | 85,892 KB |
スコア | 4,771,540 |
最終ジャッジ日時 | 2022-07-30 17:06:26 |
合計ジャッジ時間 | 31,932 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 946 ms
84,580 KB |
testcase_01 | AC | 948 ms
85,884 KB |
testcase_02 | AC | 950 ms
85,744 KB |
testcase_03 | AC | 948 ms
85,192 KB |
testcase_04 | AC | 958 ms
85,088 KB |
testcase_05 | AC | 949 ms
84,532 KB |
testcase_06 | AC | 949 ms
84,944 KB |
testcase_07 | AC | 949 ms
84,592 KB |
testcase_08 | AC | 952 ms
85,680 KB |
testcase_09 | AC | 948 ms
85,436 KB |
testcase_10 | AC | 949 ms
85,892 KB |
testcase_11 | AC | 950 ms
84,648 KB |
testcase_12 | AC | 951 ms
85,100 KB |
testcase_13 | AC | 950 ms
84,624 KB |
testcase_14 | AC | 948 ms
84,648 KB |
testcase_15 | AC | 948 ms
85,060 KB |
testcase_16 | AC | 949 ms
84,960 KB |
testcase_17 | AC | 947 ms
84,712 KB |
testcase_18 | AC | 951 ms
85,060 KB |
testcase_19 | AC | 948 ms
85,356 KB |
testcase_20 | AC | 951 ms
85,388 KB |
testcase_21 | AC | 949 ms
85,432 KB |
testcase_22 | AC | 974 ms
85,068 KB |
testcase_23 | AC | 961 ms
84,804 KB |
testcase_24 | AC | 958 ms
84,988 KB |
testcase_25 | AC | 948 ms
84,844 KB |
testcase_26 | AC | 957 ms
85,188 KB |
testcase_27 | AC | 947 ms
84,772 KB |
testcase_28 | AC | 959 ms
84,960 KB |
testcase_29 | AC | 952 ms
85,208 KB |
ソースコード
import sys import time import random from heapq import heapify, heappush, heappop input = lambda: sys.stdin.readline().rstrip() # ----------------------- # n, m = map(int, input().split()) ab = [tuple(map(int, input().split())) for _ in range(n)] ab_set = set(ab) ALP = 5 LIMIT = 0.85 START = time.time() def calc_score(root): ans = 0 E = [] for i in range(1, n): u, v = root[i][1]-1, root[i-1][1]-1 tmp = (ab[u][0] - ab[v][0])**2 + (ab[u][1] - ab[v][1])**2 heappush(E, (tmp, i)) if len(E) > 8: heappop(E) ans += ALP * ALP * tmp v = root[-1][1] tmp = (ab[0][0] - ab[v][0])**2 + (ab[0][1] - ab[v][1])**2 ans += ALP * ALP * tmp heappush(E, (tmp, n)) if len(E) > 8: heappop(E) stations = [] E.sort(key=lambda x: x[1]) for c,i in E: if i == n: v = root[-1][1]-1 stations.append(((ab[0][0] + ab[v][0])//2, (ab[0][1] + ab[v][1])//2)) ans -= c * ALP * ALP ans += c * ALP else: u, v = root[i][1]-1, root[i-1][1]-1 stations.append(((ab[u][0] + ab[v][0])//2, (ab[u][1] + ab[v][1])//2)) ans -= c * ALP * ALP ans += c * ALP for i in range(8): if E[i][1] + i > len(root): root.append((E[i][1]+i, (2, i+1, 0))) else: root.insert(E[i][1]+i, (2, i+1, 0)) return root, stations, ans def make_stations(): stations = [] return stations def make_root(): A = [(1, i, ab[i-1]) for i in range(1, n+1)] C = A[1:] c = [] d = random.randint(80, 600) for i in (range(1000//d+2)): for j in (range(1000//d+2)): tmp = [] for k in C: if d*i <= k[2][0] <= d*(i+1) and d*j <= k[2][1] <= d*(j+1): tmp.append(k) for t in tmp: C.remove(t) tmp.sort(key=lambda x: x[2]) c.extend(tmp) return A[:1] + c vestscore = float('inf') st, ro = [], [] while time.time() - START < LIMIT: root = make_root() root, stations, score = calc_score(root) if score < vestscore: vestscore = score st = stations[:] ro = root[:] for i,j in st: print(i, j) print(len(ro)+1) for i,j,_ in ro: print(i, j) print(1, 1)