結果

問題 No.2909 Imaginary Summer
ユーザー 👑 p-adicp-adic
提出日時 2024-09-28 20:47:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,577 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 181,128 KB
最終ジャッジ日時 2024-10-02 17:44:24
合計ジャッジ時間 74,816 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4,038 ms
181,128 KB
testcase_01 AC 4,041 ms
78,324 KB
testcase_02 AC 4,038 ms
78,176 KB
testcase_03 AC 4,040 ms
78,264 KB
testcase_04 AC 4,040 ms
78,236 KB
testcase_05 AC 4,041 ms
78,144 KB
testcase_06 AC 4,048 ms
77,996 KB
testcase_07 AC 4,043 ms
79,020 KB
testcase_08 AC 4,040 ms
77,908 KB
testcase_09 WA -
testcase_10 AC 4,232 ms
109,108 KB
testcase_11 AC 4,172 ms
113,508 KB
testcase_12 AC 4,409 ms
124,508 KB
testcase_13 AC 4,244 ms
112,640 KB
testcase_14 AC 4,136 ms
107,048 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 TLE -
testcase_19 WA -
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

R=range
import time
import random
import math
def TwoDimensionalAllNearestNeighbourRandomisedDouble(d,S,T,bucket_size,time_bound):
	S_size = len(S); T_size = len(T)
	if S_size == 0:return[]
	assert( T_size > 0 )
	answer = [0]*S_size
	line = [0]*T_size
	now = time.time()
	time_bound /= 1000
	while time.time() - now < time_bound:
		theta = random.randint( -1000 , 1000 ) * 0.00314
		dx = math.cos( theta ); dy = math.sin( theta )
		def proj( v ):return v[0] * dx + v[1] * dy
		for j in R(T_size):line[j] = [ proj( T[j] ) , j ]
		line.sort()
		for i in R(S_size):
			proj_i = [ proj( S[i] ) , 0 ]
			l , r = 0 , T_size
			while l + 1 < r:
				m = ( l + r ) >> 1
				if proj_i < line[m]:r = m
				else:l = m
			j_llim = max( -1 , l - bucket_size - 1 )
			j_ulim = min( T_size , l + bucket_size + 1 )
			d_opt = d( S[i] , T[answer[i]] )
			for j in R(l-1,j_llim,-1):
				d_temp = d( S[i] , T[line[j][1]] )
				if d_opt > d_temp:
					d_opt = d_temp
					answer[i] = line[j][1]
				elif abs( line[j][0] - proj_i[0] ) > d_opt:break
			for j in R(l,j_ulim):
				d_temp = d( S[i] , T[line[j][1]] )
				if d_opt > d_temp:
					d_opt = d_temp
					answer[i] = line[j][1]
				elif abs( line[j][0] - proj_i[0] ) > d_opt:break
	return answer

def D(u,v):return ((u[0]-v[0])**2+(u[1]-v[1])**2)**0.5

J=lambda:list(map(int,input().split()))
N,M,K=J()
N+=1
XY=[J()for i in R(N)]
AB=[J()for k in R(K)]
d=min(D(XY[0],XY[i])for i in R(1,N))
ann=TwoDimensionalAllNearestNeighbourRandomisedDouble(D,AB,XY,100,4000)
answer=sum(min(D(XY[0],AB[k]),d+D(XY[ann[k]],AB[k]))for k in R(K))
print(answer*2)
0