結果
| 問題 | No.1999 Lattice Teleportation |
| コンテスト | |
| ユーザー |
MasKoaTS
|
| 提出日時 | 2022-06-23 17:00:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 735 ms / 2,000 ms |
| コード長 | 1,328 bytes |
| 記録 | |
| コンパイル時間 | 511 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 115,456 KB |
| 最終ジャッジ日時 | 2024-11-08 11:09:51 |
| 合計ジャッジ時間 | 14,337 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 |
ソースコード
import itertools as iter
import collections as coll
import heapq as hq
import bisect as bis
from decimal import Decimal as dec
from functools import cmp_to_key
import math
import sys
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
sys.setrecursionlimit(10 ** 6)
inp = sys.stdin.readline
input = lambda : inp().rstrip()
getN = lambda : int(inp())
getNs = lambda : map(int, inp().split())
getList = lambda :list(map(int, inp().split()))
getStrs = lambda n : [input() for _ in [0] * n]
def yexit(): print("Yes"); exit(0)
def nexit(): print("No"); exit(0)
pi = 3.141592653589793
mod = 1000000007
MOD = 998244353
INF = 4611686018427387903
dx = [1, 0, -1, 0]; dy = [0, 1, 0, -1]
class Vector2:
def __init__(self, x: int, y: int):
self.x = x
self.y = y
def __lt__(self, other):
return area(self, other) > 0
def area(v1: Vector2, v2: Vector2) -> int:
return v1.x * v2.y - v1.y * v2.x
"""
Main Code
"""
n = getN()
vector = []
for x, y in [getList() for _ in [0] * n]:
if(x == 0 and y == 0):
continue
if(y < 0):
x = -x
y = -y
vector.append(Vector2(x, y))
vector.sort()
S, bh = 0, 0
lx, ly = 0, 0
for v in vector:
v1 = Vector2(lx, ly)
v2 = Vector2(lx + v.x, ly + v.y)
S += area(v1, v2) % mod
S %= mod
bh += math.gcd(v.x, v.y)
bh %= mod
lx, ly = v2.x, v2.y
ans = (S + bh + 1) % mod
print(ans)
MasKoaTS