結果

問題 No.1797 永遠のグリッド
ユーザー H3PO4H3PO4
提出日時 2022-01-01 00:25:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 544 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 49,968 KB
最終ジャッジ日時 2024-04-17 16:13:46
合計ジャッジ時間 18,119 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 464 ms
49,968 KB
testcase_01 AC 564 ms
44,076 KB
testcase_02 AC 564 ms
44,148 KB
testcase_03 AC 565 ms
43,816 KB
testcase_04 AC 565 ms
43,948 KB
testcase_05 AC 464 ms
44,200 KB
testcase_06 AC 465 ms
44,456 KB
testcase_07 AC 464 ms
43,956 KB
testcase_08 AC 458 ms
43,824 KB
testcase_09 AC 546 ms
44,204 KB
testcase_10 AC 459 ms
43,828 KB
testcase_11 AC 479 ms
43,960 KB
testcase_12 AC 504 ms
43,816 KB
testcase_13 AC 505 ms
44,464 KB
testcase_14 AC 472 ms
44,332 KB
testcase_15 AC 485 ms
44,468 KB
testcase_16 AC 496 ms
44,212 KB
testcase_17 AC 1,813 ms
44,588 KB
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, dtype=np.int32)).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))
    g4 = np.tile(grid, (2, 2))
    for h, w in itertools.product(range(H), range(W)):
        if pow_hash(g4[h:h + H, w:w + W].data) in st:
            break
    else:
        st.add(pow_hash(grid))
print(len(st))
0