結果
問題 | No.132 点と平面との距離 |
ユーザー | Mao-beta |
提出日時 | 2024-03-15 11:44:40 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 3,053 ms / 5,000 ms |
コード長 | 1,573 bytes |
コンパイル時間 | 303 ms |
コンパイル使用メモリ | 82,228 KB |
実行使用メモリ | 77,748 KB |
最終ジャッジ日時 | 2024-09-30 00:00:14 |
合計ジャッジ時間 | 5,450 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 221 ms
77,396 KB |
testcase_01 | AC | 937 ms
77,276 KB |
testcase_02 | AC | 3,053 ms
77,748 KB |
ソースコード
import sys import math import bisect from heapq import heapify, heappop, heappush from collections import deque, defaultdict, Counter from functools import lru_cache from itertools import accumulate, combinations, permutations, product sys.setrecursionlimit(1000000) MOD = 10 ** 9 + 7 MOD99 = 998244353 input = lambda: sys.stdin.readline().strip() NI = lambda: int(input()) NMI = lambda: map(int, input().split()) NLI = lambda: list(NMI()) SI = lambda: input() SMI = lambda: input().split() SLI = lambda: list(SMI()) EI = lambda m: [NLI() for _ in range(m)] def cross3(X, Y): return [X[(i+1)%3]*Y[(i+2)%3]-X[(i+2)%3]*Y[(i+1)%3] for i in range(3)] def dist_P_from_plane_of_3points(P, Qs): Q0 = [p - x for p, x in zip(P, Qs[0])] Q1 = [p - x for p, x in zip(P, Qs[1])] Q2 = [p - x for p, x in zip(P, Qs[2])] Q01 = [Q1[i] - Q0[i] for i in range(3)] Q02 = [Q2[i] - Q0[i] for i in range(3)] R = cross3(Q01, Q02) a, b, c = R x, y, z = Q0 d = a*x + b*y + c*z return abs(d / math.sqrt(a**2+b**2+c**2)) def main(): N = NI() # P = [int(s.replace(".", "")) for s in SLI()] P = list(map(float, SMI())) XYZ = [] for _ in range(N): # xyz = [int(s.replace(".", "")) for s in SLI()] xyz = list(map(float, SMI())) XYZ.append(xyz) ans = 0 for i in range(N): for j in range(i+1, N): for k in range(j+1, N): ans += dist_P_from_plane_of_3points(P, [XYZ[i], XYZ[j], XYZ[k]]) # print(ans / 10**6) print(ans) if __name__ == "__main__": main()