結果
問題 | No.1999 Lattice Teleportation |
ユーザー | vwxyz |
提出日時 | 2023-09-03 00:11:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,522 ms / 2,000 ms |
コード長 | 1,862 bytes |
コンパイル時間 | 835 ms |
コンパイル使用メモリ | 81,664 KB |
実行使用メモリ | 158,092 KB |
最終ジャッジ日時 | 2024-06-12 06:06:47 |
合計ジャッジ時間 | 26,126 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 156 ms
89,216 KB |
testcase_01 | AC | 155 ms
89,344 KB |
testcase_02 | AC | 155 ms
89,344 KB |
testcase_03 | AC | 156 ms
89,216 KB |
testcase_04 | AC | 163 ms
89,600 KB |
testcase_05 | AC | 185 ms
90,752 KB |
testcase_06 | AC | 186 ms
90,624 KB |
testcase_07 | AC | 170 ms
89,728 KB |
testcase_08 | AC | 165 ms
89,856 KB |
testcase_09 | AC | 157 ms
89,216 KB |
testcase_10 | AC | 157 ms
89,088 KB |
testcase_11 | AC | 192 ms
90,752 KB |
testcase_12 | AC | 1,127 ms
157,784 KB |
testcase_13 | AC | 1,467 ms
157,964 KB |
testcase_14 | AC | 155 ms
89,472 KB |
testcase_15 | AC | 1,484 ms
158,032 KB |
testcase_16 | AC | 847 ms
125,748 KB |
testcase_17 | AC | 1,340 ms
150,708 KB |
testcase_18 | AC | 1,198 ms
143,232 KB |
testcase_19 | AC | 1,286 ms
149,040 KB |
testcase_20 | AC | 1,493 ms
158,092 KB |
testcase_21 | AC | 1,522 ms
157,704 KB |
testcase_22 | AC | 1,481 ms
157,452 KB |
testcase_23 | AC | 261 ms
93,568 KB |
testcase_24 | AC | 565 ms
110,928 KB |
testcase_25 | AC | 1,192 ms
142,896 KB |
testcase_26 | AC | 1,013 ms
132,840 KB |
testcase_27 | AC | 861 ms
125,972 KB |
testcase_28 | AC | 1,420 ms
152,024 KB |
testcase_29 | AC | 720 ms
118,480 KB |
testcase_30 | AC | 407 ms
101,632 KB |
testcase_31 | AC | 354 ms
98,560 KB |
testcase_32 | AC | 936 ms
129,392 KB |
ソースコード
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,self.x)>=(0,0) and (other.y,other.x)<(0,0): return True if (self.y,self.x)<(0,0) and (other.y,other.x)>=(0,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)