結果

問題 No.866 レベルKの正方形
ユーザー kotatsugamekotatsugame
提出日時 2019-08-28 12:10:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,974 ms / 6,000 ms
コード長 541 bytes
コンパイル時間 804 ms
コンパイル使用メモリ 70,952 KB
実行使用メモリ 417,508 KB
最終ジャッジ日時 2023-08-11 03:41:56
合計ジャッジ時間 24,830 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 1,974 ms
417,256 KB
testcase_09 AC 1,460 ms
417,192 KB
testcase_10 AC 1,297 ms
417,192 KB
testcase_11 AC 1,831 ms
417,508 KB
testcase_12 AC 1,504 ms
417,320 KB
testcase_13 AC 1,894 ms
417,204 KB
testcase_14 AC 1,525 ms
417,184 KB
testcase_15 AC 1,733 ms
417,252 KB
testcase_16 AC 1,668 ms
417,380 KB
testcase_17 AC 1,576 ms
417,192 KB
testcase_18 AC 1,777 ms
417,196 KB
testcase_19 AC 1,950 ms
417,192 KB
testcase_20 AC 1,666 ms
417,320 KB
testcase_21 AC 712 ms
417,176 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 2 ms
5,668 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int H,W,K;
string s[2000];
int dp[2000][2000][26];
main()
{
	cin>>H>>W>>K;
	for(int i=0;i<H;i++)cin>>s[i];
	for(int i=H;i--;)for(int j=W;j--;)
	{
		for(int c=0;c<26;c++)
		{
			dp[i][j][c]=min({i+1<H?dp[i+1][j][c]:H-i,j+1<W?dp[i][j+1][c]:W-j,i+1<H&&j+1<W?dp[i+1][j+1][c]:2000})+1;
		}
		dp[i][j][s[i][j]-'a']=1;
	}
	long ans=0;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)
	{
		sort(dp[i][j],dp[i][j]+26);
		ans+=(K<26?dp[i][j][K]:min(H-i,W-j)+1)-dp[i][j][K-1];
	}
	cout<<ans<<endl;
}
0