結果
問題 | No.2602 Real Collider |
ユーザー |
|
提出日時 | 2024-01-12 22:32:46 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,521 bytes |
コンパイル時間 | 282 ms |
コンパイル使用メモリ | 82,472 KB |
実行使用メモリ | 95,208 KB |
最終ジャッジ日時 | 2024-09-27 23:11:02 |
合計ジャッジ時間 | 6,380 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 64 WA * 13 TLE * 1 |
ソースコード
from fractions import Fractiondef gcd(a, b):while b:a, b = b, a % breturn aclass Fractionll:def __init__(self, x=0, y=1):self.x = xself.y = yself.reduc()def reduc(self):minus = 1absx = self.xabsy = self.yif self.x < 0:minus *= -1absx *= -1if self.y < 0:minus *= -1absy *= -1g = gcd(absx, absy)self.x = minus * absx // gself.y = absy // gdef __lt__(self, other):return self.x * other.y < self.y * other.xdef __le__(self, other):return self.x * other.y <= self.y * other.xdef __gt__(self, other):return self.x * other.y > self.y * other.xdef __ge__(self, other):return self.x * other.y >= self.y * other.xdef __eq__(self, other):return self.x == other.x and self.y == other.ydef __neg__(self):return Fractionll(-self.x, self.y)def __iadd__(self, other):self.x = self.x * other.y + self.y * other.xself.y *= other.yself.reduc()return selfdef __add__(self, other):return Fractionll(self.x, self.y).__iadd__(other)def __isub__(self, other):self.x = self.x * other.y - self.y * other.xself.y *= other.yself.reduc()return selfdef __sub__(self, other):return Fractionll(self.x, self.y).__isub__(other)def __imul__(self, other):self.x *= other.xself.y *= other.yself.reduc()return selfdef __mul__(self, other):return Fractionll(self.x, self.y).__imul__(other)def __itruediv__(self, other):self.x *= other.yself.y *= other.xself.reduc()return selfdef __truediv__(self, other):return Fractionll(self.x, self.y).__itruediv__(other)def inv(self):return Fractionll(self.y, self.x)def pow(self, t):if t < 0:return self.inv().pow(-t)a, d = Fractionll(1, 1), selfwhile t:d *= dif t & 1:a *= dt >>= 1return adef __str__(self):return f"{self.x}/{self.y}"def solve():Q = int(input())X = [0] * 3Y = [0] * 3X[0], Y[0], X[1], Y[1], X[2], Y[2] = map(int, input().split())a = X[0] - X[1]b = Y[0] - Y[1]c = X[1] - X[2]d = Y[1] - Y[2]bunbo = 2 * (a * d - b * c)if bunbo == 0:XY = sorted([(X[i], Y[i]) for i in range(3)])cx, cy = XY[1][0], XY[1][1]r2 = (X[0] - cx) ** 2 + (Y[0] - cy) ** 2for _ in range(Q):x, y = map(int, input().split())dist = (x - cx) ** 2 + (y - cy) ** 2print("Yes" if dist <= r2 else "No")returne = X[0] ** 2 + Y[0] ** 2 - (X[1] ** 2 + Y[1] ** 2)f = X[1] ** 2 + Y[1] ** 2 - (X[2] ** 2 + Y[2] ** 2)cx = Fractionll(d * e - b * f, bunbo)cy = Fractionll(-c * e + a * f, bunbo)r2 = (Fractionll(X[0], 1) - cx) * (Fractionll(X[0], 1) - cx) + (Fractionll(Y[0], 1) - cy) * (Fractionll(Y[0], 1) - cy)#print(cx.x,cx.y,cy.x,cy.y,r2)for _ in range(Q):x, y = map(int, input().split())dist = (Fractionll(x, 1) - cx) * (Fractionll(x, 1) - cx) + (Fractionll(y, 1) - cy) * (Fractionll(y, 1) - cy)#p = dist.x * r2.y#q = dist.y * r2.xprint("Yes" if dist <= r2 else "No")solve()