結果

問題 No.2179 Planet Traveler
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-01-20 11:31:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,079 bytes
コンパイル時間 1,359 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 87,108 KB
最終ジャッジ日時 2023-09-05 05:37:07
合計ジャッジ時間 11,027 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
72,856 KB
testcase_01 AC 113 ms
72,800 KB
testcase_02 AC 113 ms
72,904 KB
testcase_03 AC 107 ms
72,684 KB
testcase_04 AC 108 ms
72,848 KB
testcase_05 AC 108 ms
72,960 KB
testcase_06 AC 113 ms
72,752 KB
testcase_07 WA -
testcase_08 AC 146 ms
79,892 KB
testcase_09 AC 156 ms
79,788 KB
testcase_10 AC 134 ms
77,932 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 410 ms
85,760 KB
testcase_15 AC 419 ms
86,864 KB
testcase_16 AC 416 ms
87,108 KB
testcase_17 AC 428 ms
86,284 KB
testcase_18 WA -
testcase_19 AC 445 ms
86,096 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 334 ms
84,912 KB
testcase_23 WA -
testcase_24 AC 392 ms
85,272 KB
testcase_25 AC 344 ms
84,572 KB
testcase_26 AC 427 ms
86,240 KB
testcase_27 WA -
testcase_28 AC 294 ms
84,348 KB
testcase_29 AC 434 ms
85,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import math,sys
input = sys.stdin.readline
N = int(input())
dist = [[0]*N for _ in range(N)]
XYT = [tuple(map(int,input().split())) for _ in range(N)]

for i in range(N-1):
    xi,yi,ti = XYT[i]
    for j in range(i+1,N):
        xj,yj,tj = XYT[j]
        if ti==tj:
            td = (xi-xj)**2 + (yi-yj)**2
        else:

            
            td = xi**2+yi**2+xj**2+yj**2-2*math.floor((math.sqrt(xi**2+yi**2)*math.sqrt(xj**2+yj**2)))
                    
            
        
        dist[i][j]=td
        dist[j][i]=td

class DSU:
    def __init__(self, n):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a, b):
        assert 0 <= a < self._n
        assert 0 <= b < self._n
        x, y = self.leader(a), self.leader(b)
        if x == y: return x
        if -self.parent_or_size[x] < -self.parent_or_size[y]: x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x

    def same(self, a, b):
        assert 0 <= a < self._n
        assert 0 <= b < self._n
        return self.leader(a) == self.leader(b)

    def leader(self, a):
        assert 0 <= a < self._n
        if self.parent_or_size[a] < 0: return a
        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a):
        assert 0 <= a < self._n
        return -self.parent_or_size[self.leader(a)]

    def groups(self):
        leader_buf = [self.leader(i) for i in range(self._n)]
        result = [[] for _ in range(self._n)]
        for i in range(self._n): result[leader_buf[i]].append(i)
        return [r for r in result if r != []]


def is_ok(s):
    
    D = DSU(N)
    
    for i in range(N-1):
        for j in range(i+1,N):
            if dist[i][j]<=s:
                D.merge(i,j)
    return D.same(0,N-1)
    
x = -1
y = 10**18
while y-x>1:
    mid = (y+x)//2
    
    if is_ok(mid):
        y = mid
    else:
        x = mid
print(y)
0