結果

問題 No.866 レベルKの正方形
ユーザー tko919tko919
提出日時 2020-12-22 00:32:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,157 ms / 6,000 ms
コード長 948 bytes
コンパイル時間 1,581 ms
コンパイル使用メモリ 170,936 KB
実行使用メモリ 433,280 KB
最終ジャッジ日時 2023-10-21 12:15:14
合計ジャッジ時間 29,389 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,752 KB
testcase_01 AC 3 ms
5,752 KB
testcase_02 AC 2 ms
5,752 KB
testcase_03 AC 2 ms
5,752 KB
testcase_04 AC 2 ms
5,752 KB
testcase_05 AC 3 ms
5,752 KB
testcase_06 AC 2 ms
5,752 KB
testcase_07 AC 2 ms
5,752 KB
testcase_08 AC 2,144 ms
433,236 KB
testcase_09 AC 1,660 ms
433,280 KB
testcase_10 AC 1,478 ms
433,280 KB
testcase_11 AC 2,101 ms
433,280 KB
testcase_12 AC 1,606 ms
433,280 KB
testcase_13 AC 2,072 ms
433,280 KB
testcase_14 AC 1,725 ms
433,280 KB
testcase_15 AC 1,740 ms
433,280 KB
testcase_16 AC 1,865 ms
433,280 KB
testcase_17 AC 1,782 ms
433,280 KB
testcase_18 AC 1,805 ms
433,280 KB
testcase_19 AC 2,157 ms
433,280 KB
testcase_20 AC 1,895 ms
433,280 KB
testcase_21 AC 831 ms
433,280 KB
testcase_22 AC 2 ms
5,724 KB
testcase_23 AC 2 ms
5,724 KB
testcase_24 AC 3 ms
5,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

char s[2010][2010];
int dp[2010][2010][27];

int main(){
   int h,w,k; cin>>h>>w>>k;
   rep(i,0,h)cin>>s[i];
   for(int i=h;i>=0;i--)for(int j=w;j>=0;j--){
      rep(c,0,27){
         dp[i][j][c]=min({min(h-i,w-j)+1,dp[i][j+1][c],
            dp[i+1][j][c],dp[i+1][j+1][c]})+1;
      }
      if(islower(s[i][j]))dp[i][j][s[i][j]-'a']=1;
   }
   ll res=0;
   rep(i,0,h)rep(j,0,w){
      sort(dp[i][j],dp[i][j]+27);
      res+=dp[i][j][k]-dp[i][j][k-1];
   }
   cout<<res<<endl;
   return 0;
}
0