結果

問題 No.866 レベルKの正方形
コンテスト
ユーザー zelda_master
提出日時 2026-08-23 19:34:04
言語 C++14
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 828 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 362 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2026-08-23 19:34:38
合計ジャッジ時間 10,263 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 8 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <cstdio>
#include <set>

using namespace std;

const int N = 2010;

char ch[N][N];
int h, w, k, ans;

int main() {
    scanf("%d%d%d", &h, &w, &k);
    for (int i = 1; i <= h; ++i) {
        string s;
        cin >> s;
        for (int j = 1; j <= w; ++j) {
            ch[i][j] = s[j - 1];
        }
    }

    for (int len = 1; len <= min(h, w); ++len) {
        for (int x1 = 1; x1 <= h - len; ++x1) {
            for (int y1 = 1; y1 <= w - len; ++y1) {
                set<char> s;
                for (int i = x1; i <= x1 + len; ++i) {
                    for (int j = y1; j <= y1 + len; ++j) {
                        s.insert(ch[i][j]);
                    }
                }
                if (s.size() == k) ++ans;
            }
        }
    }

    printf("%d\n", ans);

    return 0;
}
0