結果

問題 No.866 レベルKの正方形
ユーザー chocoruskchocorusk
提出日時 2019-08-16 22:04:44
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,304 bytes
コンパイル時間 1,111 ms
コンパイル使用メモリ 104,712 KB
実行使用メモリ 418,332 KB
最終ジャッジ日時 2023-10-23 23:34:50
合計ジャッジ時間 27,778 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
56,992 KB
testcase_01 AC 12 ms
56,992 KB
testcase_02 AC 10 ms
56,992 KB
testcase_03 AC 10 ms
56,992 KB
testcase_04 AC 11 ms
56,992 KB
testcase_05 AC 10 ms
56,992 KB
testcase_06 AC 10 ms
56,992 KB
testcase_07 AC 11 ms
56,992 KB
testcase_08 AC 1,834 ms
418,292 KB
testcase_09 AC 1,827 ms
418,292 KB
testcase_10 AC 1,627 ms
418,292 KB
testcase_11 AC 2,184 ms
418,292 KB
testcase_12 AC 1,564 ms
418,292 KB
testcase_13 AC 2,096 ms
418,292 KB
testcase_14 AC 1,984 ms
418,292 KB
testcase_15 AC 1,826 ms
418,292 KB
testcase_16 AC 1,920 ms
418,292 KB
testcase_17 AC 1,822 ms
418,292 KB
testcase_18 AC 1,750 ms
418,292 KB
testcase_19 AC 1,902 ms
418,292 KB
testcase_20 AC 1,698 ms
418,292 KB
testcase_21 WA -
testcase_22 AC 12 ms
56,968 KB
testcase_23 AC 9 ms
56,968 KB
testcase_24 AC 10 ms
59,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int dp[26][2002][2002];
int h, w;
string c[2002];

int main()
{
	int k;
	cin>>h>>w>>k;
	for(int i=0; i<h; i++){
		cin>>c[i];
	}
	for(int i=0; i<h; i++){
		for(int l=0; l<26; l++){
			if(l==c[i][0]-'a') dp[l][i][0]=0;
			else dp[l][i][0]=1;
		}
	}
	for(int i=0; i<w; i++){
		for(int l=0; l<26; l++){
			if(l==c[0][i]-'a') dp[l][0][i]=0;
			else dp[l][0][i]=1;
		}
	}
	for(int i=1; i<h; i++){
		for(int j=1; j<w; j++){
			for(int l=0; l<26; l++){
				if(c[i][j]-'a'==l) dp[l][i][j]=0;
				else{
					dp[l][i][j]=min({dp[l][i-1][j-1], dp[l][i-1][j], dp[l][i][j-1]})+1;
				}
			}
		}
	}
	int ans=0;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			int x[28];
			for(int l=0; l<26; l++) x[l+1]=dp[l][i][j];
			x[0]=0, x[27]=min(i+1, j+1);
			sort(x, x+28);
			ans+=x[k+1]-x[k];
		}
	}
	cout<<ans<<endl;
	return 0;
}
0