結果

問題 No.1797 永遠のグリッド
ユーザー H3PO4H3PO4
提出日時 2022-01-01 01:03:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 310 ms / 2,000 ms
コード長 867 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 76,928 KB
最終ジャッジ日時 2024-04-17 16:58:11
合計ジャッジ時間 4,012 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
51,456 KB
testcase_01 AC 46 ms
51,840 KB
testcase_02 AC 46 ms
52,352 KB
testcase_03 AC 47 ms
52,096 KB
testcase_04 AC 46 ms
52,096 KB
testcase_05 AC 47 ms
52,096 KB
testcase_06 AC 46 ms
52,480 KB
testcase_07 AC 47 ms
51,840 KB
testcase_08 AC 47 ms
51,712 KB
testcase_09 AC 76 ms
68,224 KB
testcase_10 AC 47 ms
52,224 KB
testcase_11 AC 50 ms
52,608 KB
testcase_12 AC 80 ms
69,120 KB
testcase_13 AC 79 ms
69,888 KB
testcase_14 AC 48 ms
51,584 KB
testcase_15 AC 47 ms
51,712 KB
testcase_16 AC 53 ms
57,600 KB
testcase_17 AC 121 ms
76,288 KB
testcase_18 AC 143 ms
76,336 KB
testcase_19 AC 44 ms
51,456 KB
testcase_20 AC 197 ms
76,800 KB
testcase_21 AC 134 ms
76,416 KB
testcase_22 AC 113 ms
76,528 KB
testcase_23 AC 253 ms
76,800 KB
testcase_24 AC 102 ms
76,548 KB
testcase_25 AC 137 ms
76,136 KB
testcase_26 AC 310 ms
76,928 KB
testcase_27 AC 48 ms
52,864 KB
testcase_28 AC 44 ms
52,480 KB
testcase_29 AC 133 ms
76,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

st = set()
for b in range(K ** (H * W)):
    ct = set((b // (K ** i)) % K for i in range(H * W))
    if len(ct) != K:
        continue

    bh = b
    flag = False
    for h in range(H):
        bw = bh
        for w in range(W):
            # print(h, w, bw)
            # print(np.array([(bw // (K ** i)) % K for i in range(H * W)]).reshape((H, W)))
            if bw in st:
                flag = True
                break

            bw *= K
            for h2 in range(H):
                m = (bw // (K ** ((h2 + 1) * W))) % K
                bw += m * (K ** (h2 * W) - K ** ((h2 + 1) * W))

        if flag:
            break
        bh *= (K ** W)
        for w2 in range(W):
            m = (bh // (K ** (H * W + w2))) % K
            bh += m * (K ** w2 - K ** (H * W + w2))

    else:
        st.add(b)

print(len(st))
0