結果

問題 No.849 yuki国の分割統治
ユーザー mkawa2mkawa2
提出日時 2021-02-20 16:51:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,449 bytes
コンパイル時間 454 ms
コンパイル使用メモリ 11,964 KB
実行使用メモリ 45,792 KB
最終ジャッジ日時 2023-10-17 23:52:44
合計ジャッジ時間 9,419 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,308 KB
testcase_01 AC 30 ms
10,308 KB
testcase_02 AC 30 ms
10,316 KB
testcase_03 AC 30 ms
10,308 KB
testcase_04 AC 30 ms
10,308 KB
testcase_05 AC 30 ms
10,308 KB
testcase_06 AC 30 ms
10,304 KB
testcase_07 AC 217 ms
31,000 KB
testcase_08 AC 364 ms
33,784 KB
testcase_09 AC 374 ms
33,200 KB
testcase_10 AC 400 ms
31,580 KB
testcase_11 AC 348 ms
31,448 KB
testcase_12 AC 389 ms
30,472 KB
testcase_13 AC 410 ms
34,420 KB
testcase_14 AC 388 ms
31,832 KB
testcase_15 AC 342 ms
32,540 KB
testcase_16 AC 396 ms
40,052 KB
testcase_17 AC 374 ms
29,944 KB
testcase_18 AC 405 ms
40,580 KB
testcase_19 AC 384 ms
32,180 KB
testcase_20 AC 411 ms
37,412 KB
testcase_21 AC 366 ms
29,944 KB
testcase_22 WA -
testcase_23 AC 265 ms
37,936 KB
testcase_24 AC 238 ms
31,652 KB
testcase_25 AC 413 ms
45,792 KB
testcase_26 AC 30 ms
10,300 KB
testcase_27 AC 30 ms
10,300 KB
testcase_28 AC 29 ms
10,300 KB
testcase_29 AC 29 ms
10,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def FI(): return float(sys.stdin.buffer.readline())
def MI(): return map(int, sys.stdin.buffer.readline().split())
def MF(): return map(float, sys.stdin.buffer.readline().split())
def MI1(): return map(int1, sys.stdin.buffer.readline().split())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
inf = 10**16
# md = 998244353
md = 10**9+7

from math import gcd

a, b, c, d = MI()
n = II()
xy = LLI(n)

group = set()

if a == c == 0:
    g = gcd(b, d)
    for x, y in xy:
        group.add((x, y%g))

elif b == d == 0:
    g = gcd(a, c)
    for x, y in xy:
        group.add((x%g, y))

elif a*d-b*c==0:
    gx = gcd(a, c)
    gy = gcd(b, d)
    for x, y in xy:
        group.add((x%gx, y%gy))

else:
    if c == 0: a, b, c, d = c, d, a, b
    for x, y in xy:
        m = (d*x-c*y+a*d-b*c-1)//(a*d-b*c)
        x, y = x-m*a, y-m*b
        m = x//c
        x, y = x-m*c, y-m*d
        group.add((x, y))

print(len(group))
0