結果

問題 No.866 レベルKの正方形
ユーザー gew1fw
提出日時 2025-06-12 16:33:34
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 652 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 100,596 KB
最終ジャッジ日時 2025-06-12 16:34:14
合計ジャッジ時間 8,508 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 8 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W, K = map(int, input().split())
grid = [input().strip() for _ in range(H)]

count = 0

for s in range(1, min(H, W) + 1):
    max_i = H - s
    for i in range(max_i + 1):
        col_masks = []
        for j in range(W):
            mask = 0
            for di in range(s):
                c = grid[i + di][j]
                mask |= 1 << (ord(c) - ord('a'))
            col_masks.append(mask)
        max_j = W - s
        for j_start in range(max_j + 1):
            or_mask = 0
            for dj in range(s):
                or_mask |= col_masks[j_start + dj]
            if bin(or_mask).count('1') == K:
                count += 1

print(count)
0