Submission #31198

#TimeUsernameProblemLanguageResultExecution timeMemory
31198leejseo먼 별 (KOI16_dist)Cpython 2
2 / 100
2024 ms20 KiB
class Star: def __init__(self, x, y, dx, dy): self.x = x self.y = y self.dx = dx self.dy = dy def place(self, t): x = self.x y = self.y dx = self.dx dy = self.dy return [ x + t * dx , y + t * dy] def dist(self, P, t): P1 = self.place(t) P2 = P.place(t) x1, y1 = P1[0], P1[1] x2, y2 = P2[0], P2[1] return (x2 - x1)**2 + (y2 - y1)**2 ''' def g(L, t): n = len(L) cnt = 0 for i in range(n): for j in range(i): temp = L[i].dist(L[j], t) if temp > cnt: cnt = temp return cnt ''' def CCW(P, P1, P2): x1, y1 = P[0], P[1] x2, y2 = P1[0], P1[1] x3, y3 = P2[0], P2[1] Area = (x2 - x1) * (y3 - y1) - (y2 - y1) * ( x3 - x1) Abs = abs(Area) if Area == 0 : return 0 return Area / Abs def ConvexHull(L, t): n = len(L) cor = [ i.place(t) for i in L] cor.sort() UP = [] LO = [] for q in cor: while len(UP) > 1 and CCW(UP[-2], UP[-1], q) >= 0: UP.pop() while len(LO) > 1 and CCW(LO[-2], LO[-1], q) <= 0: LO.pop() UP.append(q) LO.append(q) return UP, LO def RotCal(M, t): U, L = ConvexHull(M, t) i = 0 j = len(L)-1 while i < len(U)-1 or j > 0: if i==len(U)-1 : j-= 1 elif j == 0: i += 1 elif (U[i+1][1] - U[i][1])*(L[j][0] - L[j-1][0]) > \ (L[j][1] - L[j-1][1]) *(U[i+1][0] - U[i][0]): i+= 1 else: j-= 1 x1, y1 = U[i][0], U[i][1] x2, y2 = L[j][0], L[j][1] return (x2 - x1)**2 + (y2 - y1)**2 def g(L, t): return RotCal(L, t) def f(L, P): lo = 0 hi = P while (lo <= hi): llh = (2*lo + hi)//3 lhh = (lo + 2*hi + 1)//3 if g(L, llh) <= g(L, lhh): hi = lhh-1 else: lo = llh+1 return [lo, g(L, lo)] def main(): n, T = map(int, raw_input().split()) L = [] for i in range(n): x, y, dx, dy = map(int, raw_input().split()) L.append(Star(x, y, dx, dy)) k = f(L, T) print k[0] print k[1] return main()
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...