結果

問題 No.601 Midpoint Erase
ユーザー daku9640daku9640
提出日時 2017-12-02 03:59:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 1,031 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 270,968 KB
最終ジャッジ日時 2024-05-06 00:53:16
合計ジャッジ時間 3,882 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
16,384 KB
testcase_01 AC 30 ms
11,136 KB
testcase_02 AC 26 ms
10,880 KB
testcase_03 MLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import defaultdict
from itertools import combinations
readline = sys.stdin.readline
f = lambda x, y: (True if (x[0] - y[0]) % 2 == 0 and (x[0] - y[0]) not in (-1, 0, 1) and
                          (x[1] - y[1]) % 2 == 0 and (x[1] - y[1]) not in (-1, 0, 1) else False)
N = int(input())
li = tuple(tuple(map(int, readline().split())) for _ in range(N))
MAP = defaultdict(set)
LIST = []
for x, y in ((i, j) for i, j in combinations(li, 2) if f(i, j)):
    MAP[x].add(y)
    MAP[y].add(x)
    LIST.append({x, y})
cnt = 0
dp = [LIST[0]] if LIST else []
while dp:
    fi, se = dp.pop()
    if MAP[fi] and MAP[se]:
        for z in MAP[fi]:
            MAP[z].remove(fi)
            if not MAP[z]:
                del MAP[z]
        for z in MAP[se]:
            MAP[z].remove(se)
            if not MAP[z]:
                del MAP[z]
        del MAP[fi]
        del MAP[se]
        cnt += 1
    if MAP:
        t = tuple(MAP)[0]
        dp.append((t, min(MAP[t])))
print("Bob" if cnt % 2 == 0 else "Alice")
0