結果
| 問題 | No.3437 [Cherry 8th Tune C] Silhouette |
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2025-05-06 14:23:12 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 654 ms / 2,000 ms |
| コード長 | 2,798 bytes |
| 記録 | |
| コンパイル時間 | 447 ms |
| コンパイル使用メモリ | 83,004 KB |
| 実行使用メモリ | 81,696 KB |
| 最終ジャッジ日時 | 2026-01-23 20:53:54 |
| 合計ジャッジ時間 | 8,752 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 |
ソースコード
class Point_3D:
def __init__(self, x: int, y: int, z: int):
self.__x = x
self.__y = y
self.__z = z
@property
def x(self) -> int:
return self.__x
@property
def y(self) -> int:
return self.__y
@property
def z(self) -> int:
return self.__z
def __sub__(self, other: "Point_3D") -> "Point_3D":
return Point_3D(self.x - other.x, self.y - other.y, self.z - other.z)
Mod = 998244353
Fp = int
class Point_2D:
def __init__(self, x: Fp, y: Fp):
self.__x = x
self.__y = y
@property
def x(self) -> Fp:
return self.__x
@property
def y(self) -> Fp:
return self.__y
def __sub__(self, other: "Point_2D") -> "Point_2D":
return Point_2D(self.x - other.x, self.y - other.y)
#==================================================
def calculate_shadow(L: Point_3D, P: Point_3D) -> Point_2D:
""" 点光源 L における点 P の xy 平面への影の座標の x, y 座標を求める.
Args:
L (Point_3D): 光源
P (Point_3D): 実態となる点
Returns:
Point_2D: 影 (x, y)
"""
qx = P.x - L.x
qy = P.y - L.y
qz = P.z
rx = (L.z * qx) % Mod * pow(L.z - qz, -1, Mod) % Mod
ry = (L.z * qy) % Mod * pow(L.z - qz, -1, Mod) % Mod
return Point_2D(rx, ry)
def triangle_area(A: Point_2D, B: Point_2D, C: Point_2D) -> Fp:
""" 座標平面上の三角形 ABC の面積を求める.
Args:
A (Point_2D):
B (Point_2D):
C (Point_2D):
Returns:
Fp: 三角形 ABC の符号付き面積
"""
u = B - A
v = C - A
return (u.x * v.y - u.y * v.x) % Mod * pow(2, -1, Mod) % Mod
def det(O: Point_3D, A: Point_3D, B: Point_3D, C: Point_3D) -> int:
""" 三角錐 OABC の符号付き面積を求める.
Args:
O (Point_3D):
A (Point_3D):
B (Point_3D):
C (Point_3D):
Returns:
int: 三角錐 OABC の符号付き面積
"""
A = A - O
B = B - O
C = C - O
plus = A.x * B.y * C.z + A.y * B.z * C.x + A.z * B.x * C.y
minus = A.x * B.z * C.y + A.z * B.y * C.x + A.y * B.x * C.z
return plus - minus
#==================================================
def point_input() -> Point_3D:
a, b, c = map(int, input().split())
return Point_3D(a, b, c)
def solve():
P1, P2, P3 = [point_input() for _ in range(3)]
R = point_input()
if det(R, P1, P2, P3) >= 0:
P2, P3 = P3, P2
shadows = [calculate_shadow(R, P) for P in [P1, P2, P3]]
return triangle_area(*shadows)
#==================================================
import sys
input = sys.stdin.readline
write = sys.stdout.write
T = int(input())
write("\n".join(map(str, [solve() for _ in range(T)])))
Kazun