結果

問題 No.1999 Lattice Teleportation
ユーザー MasKoaTSMasKoaTS
提出日時 2022-02-22 18:13:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 822 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 30,468 KB
最終ジャッジ日時 2024-04-25 22:58:30
合計ジャッジ時間 16,454 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
11,008 KB
testcase_01 AC 29 ms
11,008 KB
testcase_02 AC 28 ms
10,880 KB
testcase_03 AC 26 ms
11,008 KB
testcase_04 AC 26 ms
10,880 KB
testcase_05 AC 32 ms
11,008 KB
testcase_06 AC 33 ms
11,008 KB
testcase_07 AC 30 ms
10,880 KB
testcase_08 AC 28 ms
11,008 KB
testcase_09 AC 31 ms
10,880 KB
testcase_10 AC 27 ms
11,008 KB
testcase_11 AC 33 ms
11,008 KB
testcase_12 AC 854 ms
30,344 KB
testcase_13 AC 1,112 ms
30,340 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 604 ms
20,712 KB
testcase_17 AC 1,019 ms
27,244 KB
testcase_18 AC 875 ms
25,480 KB
testcase_19 AC 935 ms
26,304 KB
testcase_20 AC 1,132 ms
30,352 KB
testcase_21 AC 1,129 ms
30,340 KB
testcase_22 AC 1,108 ms
30,348 KB
testcase_23 AC 93 ms
12,160 KB
testcase_24 AC 344 ms
16,836 KB
testcase_25 AC 867 ms
25,200 KB
testcase_26 AC 703 ms
22,780 KB
testcase_27 AC 586 ms
20,716 KB
testcase_28 AC 1,035 ms
27,756 KB
testcase_29 AC 485 ms
18,820 KB
testcase_30 AC 210 ms
14,464 KB
testcase_31 AC 164 ms
13,696 KB
testcase_32 AC 644 ms
21,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import cmp_to_key
from math import gcd
import sys
input = sys.stdin.readline
mod = 10 ** 9 + 7

def get_mod(n):
	if(n < 0):
		return mod - (-n) % mod
	return n % mod

def area(v1, v2):
	x1, y1 = get_mod(v1[0]), get_mod(v1[1])
	x2, y2 = get_mod(v2[0]), get_mod(v2[1])
	return get_mod(x1 * y2 % mod - x2 * y1 % mod)

def arg_sort(v1, v2):
	x1, y1 = v1
	x2, y2 = v2
	if(x1 * y2 == x2 * y1):
		return 0
	elif(x1 * y2 - x2 * y1 < 0):
		return 1
	else:
		return -1

n = int(input())
v = []
for _ in [0] * n:
	x, y = map(int, input().split())
	if(y < 0):
		x = -x;		y = -y
	v.append((x, y))
v.sort(key = cmp_to_key(arg_sort))

S, bh = 0, 0
lx, ly = 0, 0
for x, y in v:
	v1 = (lx, ly)
	v2 = (lx + x, ly + y)
	S += area(v1, v2)
	S %= mod
	bh += gcd(x, y)
	bh %= mod
	lx, ly = v2

ans = (S + bh + 1) % mod
print(ans)
0