結果

問題 No.1797 永遠のグリッド
ユーザー H3PO4H3PO4
提出日時 2022-01-01 01:08:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 506 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 50,640 KB
最終ジャッジ日時 2024-04-17 17:02:17
合計ジャッジ時間 17,753 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 531 ms
49,844 KB
testcase_01 AC 530 ms
44,204 KB
testcase_02 AC 530 ms
44,592 KB
testcase_03 AC 537 ms
43,956 KB
testcase_04 AC 532 ms
44,344 KB
testcase_05 AC 532 ms
44,080 KB
testcase_06 AC 524 ms
44,208 KB
testcase_07 AC 533 ms
44,212 KB
testcase_08 AC 536 ms
43,948 KB
testcase_09 AC 668 ms
44,468 KB
testcase_10 AC 554 ms
44,216 KB
testcase_11 AC 550 ms
44,464 KB
testcase_12 AC 608 ms
44,332 KB
testcase_13 AC 602 ms
44,336 KB
testcase_14 AC 541 ms
44,204 KB
testcase_15 AC 529 ms
44,216 KB
testcase_16 AC 543 ms
44,088 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
import itertools

H, W, K = map(int, input().split())

pow_table = (K ** np.arange(H * W)).reshape((H, W))
pow_hash = lambda x: np.sum(x * pow_table)

st = set()
for t in itertools.product(range(K), repeat=H * W):
    if len(set(t)) != K:
        continue
    grid = np.array(t).reshape((H, W))
    for h, w in itertools.product(range(H), range(W)):
        if pow_hash(np.roll(grid, (h, w), axis=(0, 1))) in st:
            break
    else:
        st.add(pow_hash(grid))
print(len(st))
0