結果
| 問題 |
No.602 隠されていたゲーム2
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 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.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from bisect import bisect_left, bisect_right
N = 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 + y
else:
return x + y - d, d + x + y
D_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 0
if x + y in D:
return 1
for d in D:
d1, d2 = dist_range(d)
A = D_od if d1 & 1 else D_ev
if bisect_right(A, d2) - bisect_left(A, d1):
return 2
return - 1
print(solve())
maspy