結果

問題 No.866 レベルKの正方形
ユーザー kotatsugamekotatsugame
提出日時 2019-08-17 03:52:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 659 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 66,704 KB
実行使用メモリ 417,684 KB
最終ジャッジ日時 2023-10-24 23:23:32
合計ジャッジ時間 43,615 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2,256 ms
417,680 KB
testcase_09 AC 2,344 ms
417,680 KB
testcase_10 AC 2,940 ms
417,680 KB
testcase_11 AC 3,012 ms
417,680 KB
testcase_12 AC 3,318 ms
417,680 KB
testcase_13 AC 3,029 ms
417,680 KB
testcase_14 AC 3,388 ms
417,680 KB
testcase_15 AC 2,771 ms
417,680 KB
testcase_16 AC 3,292 ms
417,680 KB
testcase_17 AC 2,873 ms
417,680 KB
testcase_18 AC 2,907 ms
417,680 KB
testcase_19 AC 3,214 ms
417,680 KB
testcase_20 AC 2,743 ms
417,680 KB
testcase_21 WA -
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int H,W,K;
string s[2000];
int sum[2001][2001][26];
int f(int x,int y,int k)
{
	int L=1,R=(H-x<W-y?H-x:W-y)+1;
	while(R-L>1)
	{
		int M=(L+R)/2;
		int cnt=0;
		for(int c=0;c<26;c++)
		{
			cnt+=sum[x+M][y+M][c]-sum[x+M][y][c]-sum[x][y+M][c]+sum[x][y][c]>0;
		}
		if(cnt<k)L=M;
		else R=M;
	}
	return R;
}
main()
{
	cin>>H>>W>>K;
	for(int i=0;i<H;i++)cin>>s[i];
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)for(int c=0;c<26;c++)
	{
		sum[i+1][j+1][c]=sum[i+1][j][c]+sum[i][j+1][c]-sum[i][j][c]+(s[i][j]==c+'a');
	}
	long ans=0;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)
	{
		ans+=f(i,j,K+1)-f(i,j,K);
	}
	cout<<ans<<endl;
}
0