結果

問題 No.866 レベルKの正方形
ユーザー kotatsugamekotatsugame
提出日時 2019-08-17 04:14:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4,184 ms / 6,000 ms
コード長 708 bytes
コンパイル時間 531 ms
コンパイル使用メモリ 61,244 KB
実行使用メモリ 409,708 KB
最終ジャッジ日時 2023-10-24 23:43:19
合計ジャッジ時間 51,362 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,399 ms
409,708 KB
testcase_09 AC 2,534 ms
409,516 KB
testcase_10 AC 3,164 ms
409,620 KB
testcase_11 AC 3,691 ms
409,708 KB
testcase_12 AC 3,807 ms
409,704 KB
testcase_13 AC 3,482 ms
409,704 KB
testcase_14 AC 4,184 ms
409,704 KB
testcase_15 AC 3,039 ms
409,704 KB
testcase_16 AC 3,693 ms
409,704 KB
testcase_17 AC 3,166 ms
409,704 KB
testcase_18 AC 3,292 ms
409,704 KB
testcase_19 AC 3,824 ms
409,704 KB
testcase_20 AC 3,146 ms
409,704 KB
testcase_21 AC 3,946 ms
409,704 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   21 | main()
      | ^~~~

ソースコード

diff #

#include<ios>
using namespace std;
int H,W,K;
int sum[2001][2001][26];
inline int f(int x,int y,int k)
{
	int L=0,R=(H-x<W-y?H-x:W-y)+1;
	while(R-L>1)
	{
		int M=L+R>>1;
		int cnt=k;
		for(int c=0;c<26;c++)
		{
			if(sum[x+M][y+M][c]-sum[x+M][y][c]-sum[x][y+M][c]+sum[x][y][c])cnt--;
		}
		if(cnt>0)L=M;
		else R=M;
	}
	return R;
}
main()
{
	scanf("%d%d%d",&H,&W,&K);
	for(int i=0;i<H;i++)
	{
		getchar_unlocked();
		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];
			}
			sum[i+1][j+1][getchar_unlocked()-'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);
	}
	printf("%ld\n",ans);
}
0