結果

問題 No.1999 Lattice Teleportation
ユーザー MasKoaTSMasKoaTS
提出日時 2022-06-23 17:00:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 788 ms / 2,000 ms
コード長 1,328 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 82,440 KB
実行使用メモリ 115,796 KB
最終ジャッジ日時 2024-04-25 23:00:55
合計ジャッジ時間 14,622 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
86,452 KB
testcase_01 AC 127 ms
86,484 KB
testcase_02 AC 123 ms
86,568 KB
testcase_03 AC 124 ms
86,608 KB
testcase_04 AC 129 ms
86,628 KB
testcase_05 AC 147 ms
89,548 KB
testcase_06 AC 147 ms
89,588 KB
testcase_07 AC 148 ms
89,200 KB
testcase_08 AC 128 ms
86,652 KB
testcase_09 AC 126 ms
86,660 KB
testcase_10 AC 126 ms
86,484 KB
testcase_11 AC 147 ms
89,528 KB
testcase_12 AC 596 ms
115,292 KB
testcase_13 AC 770 ms
115,412 KB
testcase_14 AC 126 ms
86,624 KB
testcase_15 AC 778 ms
115,796 KB
testcase_16 AC 471 ms
103,068 KB
testcase_17 AC 717 ms
112,784 KB
testcase_18 AC 648 ms
108,916 KB
testcase_19 AC 670 ms
111,868 KB
testcase_20 AC 772 ms
115,492 KB
testcase_21 AC 776 ms
115,460 KB
testcase_22 AC 788 ms
115,420 KB
testcase_23 AC 196 ms
90,548 KB
testcase_24 AC 343 ms
97,188 KB
testcase_25 AC 637 ms
108,280 KB
testcase_26 AC 554 ms
105,804 KB
testcase_27 AC 484 ms
102,856 KB
testcase_28 AC 735 ms
114,256 KB
testcase_29 AC 409 ms
100,096 KB
testcase_30 AC 258 ms
93,136 KB
testcase_31 AC 232 ms
92,612 KB
testcase_32 AC 506 ms
104,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0