結果

問題 No.2675 KUMA
ユーザー 👑 rin204rin204
提出日時 2024-03-15 21:59:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 950 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 75,892 KB
最終ジャッジ日時 2024-03-15 21:59:23
合計ジャッジ時間 5,530 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 50 ms
64,052 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 211 ms
75,736 KB
testcase_06 AC 141 ms
75,892 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 110 ms
75,500 KB
testcase_10 AC 222 ms
75,808 KB
testcase_11 AC 231 ms
75,808 KB
testcase_12 AC 69 ms
64,080 KB
testcase_13 AC 50 ms
64,504 KB
testcase_14 AC 51 ms
64,068 KB
testcase_15 AC 37 ms
53,460 KB
testcase_16 AC 130 ms
64,600 KB
testcase_17 AC 37 ms
53,460 KB
testcase_18 AC 37 ms
53,460 KB
testcase_19 WA -
testcase_20 AC 38 ms
53,460 KB
testcase_21 WA -
testcase_22 AC 42 ms
59,704 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 43 ms
59,704 KB
testcase_27 AC 46 ms
61,988 KB
testcase_28 WA -
testcase_29 AC 51 ms
64,484 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 53 ms
64,064 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 63 ms
68,216 KB
testcase_37 AC 63 ms
68,224 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 93 ms
75,368 KB
testcase_44 AC 90 ms
75,432 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
xy = {}
inds = set()

di = [1, 1, 2, 2, -1, -1, -2, -2]
dj = [2, -2, 1, -1, 2, -2, 1, -1]
for i in range(n):
    x, y = map(int, input().split())
    xy[(x, y)] = i
    for k in range(8):
        inds.add((x + di[k], y + dj[k]))


dp = [1 << 30] * (1 << n)
dp[0] = 0


for x, y in inds:
    if (x, y) in xy:
        continue
    ok = []
    for k in range(0, 8, 2):
        x1 = x + di[k]
        y1 = y + dj[k]
        x2 = x + di[k + 1]
        y2 = y + dj[k + 1]
        if (x1, y1) in xy and (x2, y2) in xy:
            ok.append((1 << xy[(x1, y1)]) | (1 << xy[(x2, y2)]))

        if (x1, y1) in xy:
            ok.append(1 << xy[(x1, y1)])
        if (x2, y2) in xy:
            ok.append(1 << xy[(x2, y2)])

    for bit in range((1 << n) - 1, -1, -1):
        for bit2 in ok:
            if (bit & bit2) == bit2:
                dp[bit] = min(dp[bit], dp[bit ^ bit2] + 1)

if dp[-1] > n:
    print(-1)
else:
    print(dp[-1])
0