結果
問題 | No.602 隠されていたゲーム2 |
ユーザー |
![]() |
提出日時 | 2020-03-24 22:19:46 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 179 ms / 2,000 ms |
コード長 | 791 bytes |
コンパイル時間 | 250 ms |
コンパイル使用メモリ | 12,288 KB |
実行使用メモリ | 19,972 KB |
最終ジャッジ日時 | 2025-01-01 18:36:34 |
合計ジャッジ時間 | 3,349 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#!/usr/bin/ python3.8import sysread = sys.stdin.buffer.readreadline = sys.stdin.buffer.readlinereadlines = sys.stdin.buffer.readlinesfrom bisect import bisect_left, bisect_rightN = int(readline())D = tuple(map(int, readline().split()))x, y = map(int, read().split())x = abs(x)y = abs(y)def dist_range(d):if d > x + y:return d - x - y, d + x + yelse:return x + y - d, d + x + yD_od = [x for x in D if x & 1]D_ev = [x for x in D if not (x & 1)]D_od.sort()D_ev.sort()def solve():if x == y == 0:return 0if x + y in D:return 1for d in D:d1, d2 = dist_range(d)A = D_od if d1 & 1 else D_evif bisect_right(A, d2) - bisect_left(A, d1):return 2return - 1print(solve())