結果

問題 No.866 レベルKの正方形
ユーザー erbowlerbowl
提出日時 2019-08-16 22:41:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,637 bytes
コンパイル時間 2,114 ms
コンパイル使用メモリ 176,868 KB
実行使用メモリ 431,992 KB
最終ジャッジ日時 2023-10-24 02:02:34
合計ジャッジ時間 14,256 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 4,272 ms
427,440 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef int ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,K;
    std::cin >> h>>w>>K;
    std::vector<string> s(h);
    vector<vector<vector<ll>>> sum(26,vector<vector<ll>>(h+1,vector<ll>(w+1)));
    for (int i = 0; i < h; i++) {
        std::cin >> s[i];
        for (int j = 0; j < w; j++) {
            int alpha = s[i][j]-'a';
            sum[alpha][i+1][j+1] = 1;
            for (int k = 0; k < 26; k++) {
                sum[k][i+1][j+1] += sum[k][i][j+1] + sum[k][i+1][j] - sum[k][i][j];
            }
        }
    }
    ll result = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int size = sqrt(K); size <= min(h,w); size++) {
                if(i+size<h &&  j+size<w){
                    ll num = 0;
                    for (int k = 0; k < 26; k++) {
                        ll cou;
                        cou = sum[k][i+size+1][j+size+1]-sum[k][i][j+size+1]-sum[k][i+size+1][j]+sum[k][i][j];
                        if(cou>0){
                            num++;
                        }
                    }
                    if(num==K) result++;
                    if(num>K) break;
                }else{
                    break;
                }
            }
        }
    }
    std::cout << result << std::endl;

    // 2000か。tの大きさの正方形は(2000-t)*(2000-t)通りある4 * 1e6。数えれんこともない。
    // もじの種類数
    
    // ある領域に含まれるa-zの数は出せる。
    
    // 2**26
}
0