結果

問題 No.1999 Lattice Teleportation
ユーザー vwxyzvwxyz
提出日時 2023-09-02 20:05:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,808 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 72,792 KB
最終ジャッジ日時 2023-09-02 20:06:07
合計ジャッジ時間 30,652 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,412 KB
testcase_01 AC 34 ms
10,500 KB
testcase_02 AC 33 ms
10,444 KB
testcase_03 AC 34 ms
10,580 KB
testcase_04 AC 36 ms
10,668 KB
testcase_05 AC 43 ms
11,152 KB
testcase_06 AC 42 ms
11,160 KB
testcase_07 AC 38 ms
10,828 KB
testcase_08 AC 35 ms
10,760 KB
testcase_09 AC 33 ms
10,512 KB
testcase_10 AC 34 ms
10,524 KB
testcase_11 AC 44 ms
11,132 KB
testcase_12 AC 1,545 ms
72,644 KB
testcase_13 TLE -
testcase_14 AC 33 ms
10,524 KB
testcase_15 TLE -
testcase_16 AC 976 ms
42,752 KB
testcase_17 AC 1,796 ms
64,332 KB
testcase_18 AC 1,554 ms
58,732 KB
testcase_19 AC 1,651 ms
61,564 KB
testcase_20 AC 1,986 ms
72,724 KB
testcase_21 TLE -
testcase_22 AC 1,968 ms
72,292 KB
testcase_23 AC 121 ms
14,960 KB
testcase_24 AC 550 ms
30,044 KB
testcase_25 AC 1,552 ms
58,268 KB
testcase_26 AC 1,203 ms
50,120 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')

def Declination_Sort(XY):
    class xy:
        def __init__(self,x,y):
            self.x=x
            self.y=y
        def __lt__(self,other):
            if self.y>=0 and other.y<0:
                return True
            if self.y<0 and other.y>=0:
                return False
            return self.x*other.y>self.y*other.x
    assert all(x or y for x,y in XY)
    lst=[xy(x,y) for x,y in XY]
    lst.sort()
    return [(lst[i].x,lst[i].y) for i in range(len(lst))]

N=int(readline())
mod=10**9+7
XY=[]
for n in range(N):
    x,y=map(int,readline().split())
    if x or y:
        XY.append((x,y))
        XY.append((-x,-y))
    else:
        N-=1
if not N:
    ans=1
else:
    XY=Declination_Sort(XY)
    X,Y=[0],[0]
    for x,y in XY:
        X.append(x)
        Y.append(y)
    for i in range(1,2*N+1):
        X[i]+=X[i-1]
        Y[i]+=Y[i-1]
    sum_X=sum(X)
    sum_Y=sum(Y)
    S=0
    b=0
    for x,y,xx,yy in zip(X,Y,X[1:],Y[1:]):
        S+=x*yy-y*xx
        b+=GCD(x-xx,y-yy)
    S//=2
    i=S-b//2+1
    ans=i+b
    ans%=mod
print(ans)
0