結果

問題 No.866 レベルKの正方形
ユーザー kotatsugamekotatsugame
提出日時 2019-08-28 12:07:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 539 bytes
コンパイル時間 646 ms
コンパイル使用メモリ 70,656 KB
実行使用メモリ 417,408 KB
最終ジャッジ日時 2024-04-28 20:40:11
合計ジャッジ時間 28,741 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2,220 ms
417,280 KB
testcase_09 AC 1,747 ms
417,280 KB
testcase_10 AC 1,544 ms
417,280 KB
testcase_11 AC 2,153 ms
417,152 KB
testcase_12 AC 1,776 ms
417,280 KB
testcase_13 AC 2,223 ms
417,408 KB
testcase_14 WA -
testcase_15 AC 2,066 ms
417,408 KB
testcase_16 AC 2,050 ms
417,408 KB
testcase_17 AC 1,875 ms
417,280 KB
testcase_18 AC 2,109 ms
417,280 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 920 ms
417,280 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-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))-dp[i][j][K-1];
	}
	cout<<ans<<endl;
}
0