結果
| 問題 |
No.849 yuki国の分割統治
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:59:04 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 751 bytes |
| コンパイル時間 | 214 ms |
| コンパイル使用メモリ | 82,188 KB |
| 実行使用メモリ | 104,436 KB |
| 最終ジャッジ日時 | 2025-03-31 18:00:01 |
| 合計ジャッジ時間 | 5,359 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 WA * 1 |
ソースコード
import math
from collections import defaultdict
a, b, c, d = map(int, input().split())
N = int(input())
points = [tuple(map(int, input().split())) for _ in range(N)]
D = a * d - b * c
if D != 0:
abs_D = abs(D)
groups = defaultdict(int)
for x, y in points:
r1 = (d * x - c * y) % abs_D
r2 = (-b * x + a * y) % abs_D
groups[(r1, r2)] += 1
print(len(groups))
else:
# Compute direction vector for the 1D lattice
g = math.gcd(a, b)
if a == 0 and b == 0:
# This case is invalid as per problem constraints, so not possible
pass
gx = a // g
gy = b // g
groups = defaultdict(int)
for x, y in points:
s = gy * x - gx * y
groups[s] += 1
print(len(groups))
lam6er