結果

問題 No.866 レベルKの正方形
ユーザー at_tokioat_tokio
提出日時 2019-08-17 13:20:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,314 bytes
コンパイル時間 1,697 ms
コンパイル使用メモリ 171,036 KB
実行使用メモリ 431,284 KB
最終ジャッジ日時 2023-10-25 00:18:02
合計ジャッジ時間 40,995 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,700 KB
testcase_01 AC 3 ms
5,700 KB
testcase_02 AC 3 ms
5,700 KB
testcase_03 AC 2 ms
5,700 KB
testcase_04 AC 3 ms
5,700 KB
testcase_05 AC 2 ms
5,700 KB
testcase_06 AC 2 ms
5,700 KB
testcase_07 AC 2 ms
5,700 KB
testcase_08 AC 3,137 ms
431,284 KB
testcase_09 AC 2,528 ms
431,284 KB
testcase_10 AC 2,336 ms
431,284 KB
testcase_11 AC 2,998 ms
431,284 KB
testcase_12 AC 2,614 ms
431,284 KB
testcase_13 AC 3,056 ms
431,284 KB
testcase_14 WA -
testcase_15 AC 2,908 ms
431,284 KB
testcase_16 AC 2,786 ms
431,284 KB
testcase_17 AC 2,604 ms
431,284 KB
testcase_18 AC 2,963 ms
431,284 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1,620 ms
431,284 KB
testcase_22 AC 2 ms
5,660 KB
testcase_23 AC 2 ms
5,660 KB
testcase_24 AC 3 ms
5,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60; const ll mod=1e9+7; const int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
int h,w,k;
char table[2000+5][2000+5];
int dp[2000+5][2000+5][27];
int base = int('a');

int main(){
	cin >> h >> w >> k;
	ll ans = 0;
	//memset(dp,-1,sizeof(dp));
	FOR(i,1,h) FOR(j,1,w){
		cin >> table[i][j];
	}
	for(int a=0; a<26;a++){
		for(int i=h+1; i>=1; i--){
			for(int j=w+1; j>=1; j--){
				if(table[i][j] == char(base+a)){
					dp[i][j][a] = 1; continue;
				}
				dp[i][j][a] = min(dp[i+1][j+1][a], min(dp[i+1][j][a],dp[i][j+1][a]))+1;
				dp[i][j][a] = min(dp[i][j][a], min(h+1-i, w+1-j)+1);
			}
		}
	}
	FOR(i,1,h){
		FOR(j,1,w){
			sort(dp[i][j], dp[i][j]+26);
			ans += 1LL * (dp[i][j][k] - dp[i][j][k-1]);
		}
	}
	cout << ans << endl;
    return 0;
}
0