結果

問題 No.1797 永遠のグリッド
ユーザー rlangevinrlangevin
提出日時 2023-01-21 01:11:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 329 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 87,280 KB
実行使用メモリ 82,668 KB
最終ジャッジ日時 2023-09-05 17:23:32
合計ジャッジ時間 5,844 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,380 KB
testcase_01 AC 71 ms
71,436 KB
testcase_02 AC 70 ms
71,620 KB
testcase_03 AC 71 ms
71,232 KB
testcase_04 AC 75 ms
71,312 KB
testcase_05 AC 70 ms
71,172 KB
testcase_06 AC 71 ms
71,484 KB
testcase_07 AC 70 ms
71,332 KB
testcase_08 AC 71 ms
71,584 KB
testcase_09 AC 112 ms
77,600 KB
testcase_10 AC 70 ms
71,544 KB
testcase_11 AC 77 ms
76,548 KB
testcase_12 AC 100 ms
77,600 KB
testcase_13 AC 101 ms
77,680 KB
testcase_14 AC 70 ms
71,480 KB
testcase_15 AC 70 ms
71,540 KB
testcase_16 AC 78 ms
76,668 KB
testcase_17 AC 126 ms
79,524 KB
testcase_18 AC 242 ms
82,032 KB
testcase_19 AC 71 ms
71,492 KB
testcase_20 AC 263 ms
81,676 KB
testcase_21 AC 144 ms
79,528 KB
testcase_22 AC 118 ms
77,784 KB
testcase_23 AC 296 ms
82,512 KB
testcase_24 AC 119 ms
77,996 KB
testcase_25 AC 137 ms
79,692 KB
testcase_26 AC 329 ms
82,668 KB
testcase_27 AC 78 ms
76,732 KB
testcase_28 AC 71 ms
71,336 KB
testcase_29 AC 145 ms
79,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import *

H, W, K = map(int, input().split())
S = set()
ans = 0
for tup in product(range(K), repeat=H * W):
    if len(set(tup)) != K:
        continue
    G =[[0] * W for i in range(H)]
    for j in range(H * W):
        x, y = divmod(j, W)
        G[x][y] = tup[j]
    now = 1
    v = 0
    for i in range(H):
        for j in range(W):
            v += G[(x + i)%H][(y + j)%W] * now
            now *= K
    if v not in S:
        ans += 1 
    for x in range(H):
        for y in range(W):
            now = 1
            v = 0
            for i in range(H):
                for j in range(W):
                    v += G[(x + i)%H][(y + j)%W] * now
                    now *= K
            S.add(v)
print(ans)
0