結果
| 問題 |
No.1797 永遠のグリッド
|
| ユーザー |
|
| 提出日時 | 2022-01-01 01:08:28 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 506 bytes |
| コンパイル時間 | 97 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 51,036 KB |
| 最終ジャッジ日時 | 2024-10-09 11:10:24 |
| 合計ジャッジ時間 | 15,923 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 17 TLE * 2 -- * 8 |
ソースコード
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))