結果
問題 | No.1999 Lattice Teleportation |
ユーザー | tnodino |
提出日時 | 2022-07-02 12:10:04 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,642 bytes |
コンパイル時間 | 266 ms |
コンパイル使用メモリ | 82,592 KB |
実行使用メモリ | 147,908 KB |
最終ジャッジ日時 | 2024-05-05 09:42:40 |
合計ジャッジ時間 | 14,620 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
55,040 KB |
testcase_01 | AC | 40 ms
55,040 KB |
testcase_02 | AC | 41 ms
54,784 KB |
testcase_03 | AC | 46 ms
55,168 KB |
testcase_04 | AC | 53 ms
66,304 KB |
testcase_05 | AC | 105 ms
77,952 KB |
testcase_06 | AC | 101 ms
78,192 KB |
testcase_07 | AC | 65 ms
74,240 KB |
testcase_08 | AC | 54 ms
66,048 KB |
testcase_09 | AC | 39 ms
55,040 KB |
testcase_10 | AC | 40 ms
54,400 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 728 ms
146,676 KB |
testcase_14 | AC | 42 ms
54,656 KB |
testcase_15 | AC | 739 ms
146,720 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 790 ms
147,424 KB |
testcase_21 | AC | 765 ms
147,908 KB |
testcase_22 | AC | 759 ms
147,824 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
ソースコード
from math import gcd, sqrt, acos, pi from collections import deque mod = 10**9+7 class Point: def __init__(self, px, py): self.px = px self.py = py def operator(a1, a2): return Point(a1.px - a2.px, a1.py - a2.py) def getangle(G): # 点 G の偏角を求める if G.py >= 0.0: I = G.px / sqrt(pow(G.px, 2) + pow(G.py, 2)) kaku = acos(I) * 180.0 / pi return kaku else: I = G.px / sqrt(pow(G.px, 2) + pow(G.py, 2)) kaku = acos(I) * 180.0 / pi return 360.0 - kaku # 点 p1 と p2 の外積を求める def crs(p1, p2): return p1.px * p2.py - p1.py * p2.px N = int(input()) A,B = [],[] for i in range(N): a,b = map(int,input().split()) if a == 0 and b == 0: continue if b < 0: a *= -1 b *= -1 A.append(a) B.append(b) N = len(A) vec = [] for i in range(N): SA = operator(Point(0, 0), Point(A[i], B[i])) angle = getangle(SA) vec.append([angle, i]) vec.sort() P = [[0, 0]] Q = [[0, 0]] x,y = 0,0 for i in range(N): idx = vec[i][1] x += A[idx] y += B[idx] P.append([x, y]) x,y = 0,0 for i in range(N): idx = vec[N-i-1][1] x += A[idx] y += B[idx] Q.append([x, y]) G = [] for i in range(N+1): G.append(P[i]) for i in range(N-1,0,-1): G.append(Q[i]) if len(G) == 1: print(1) exit() G.sort() for i in range(len(G)): G[i] = Point(G[i][0], G[i][1]) G1 = deque() G2 = deque() Totsuhou = [] G1.append(G[0]) G2.append(G[0]) G1.append(G[1]) G2.append(G[1]) for i in range(2,len(G)): while len(G1) >= 2 and crs(operator(G1[len(G1)-1], G1[len(G1)-2]), operator(G[i], G1[len(G1)-1])) <= 0: G1.pop() while len(G2) >= 2 and crs(operator(G2[len(G2)-1], G2[len(G2)-2]), operator(G[i], G2[len(G2)-1])) >= 0: G2.pop() G1.append(G[i]) G2.append(G[i]) G1 = list(G1) G2 = list(G2) for i in range(len(G1)): Totsuhou.append(G1[i]) for i in range(len(G2)-2,0,-1): Totsuhou.append(G2[i]) EdgePoint = len(Totsuhou) for i in range(len(Totsuhou)): ax = Totsuhou[(i+0) % len(Totsuhou)].px ay = Totsuhou[(i+0) % len(Totsuhou)].py bx = Totsuhou[(i+1) % len(Totsuhou)].px by = Totsuhou[(i+1) % len(Totsuhou)].py vx = abs(bx - ax) vy = abs(by - ay) r = gcd(vx, vy) EdgePoint += r - 1 Area = 0 for i in range(len(Totsuhou)): ax = Totsuhou[(i+0) % len(Totsuhou)].px ay = Totsuhou[(i+0) % len(Totsuhou)].py bx = Totsuhou[(i+1) % len(Totsuhou)].px by = Totsuhou[(i+1) % len(Totsuhou)].py Area += (bx - ax) * (by + ay) Area = abs(Area) Answer = Area + EdgePoint + 2 print(Answer // 2 % mod)