結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,402 ms
417,600 KB
testcase_09 AC 2,503 ms
417,680 KB
testcase_10 AC 3,445 ms
417,680 KB
testcase_11 AC 3,496 ms
417,680 KB
testcase_12 AC 3,986 ms
417,680 KB
testcase_13 AC 3,413 ms
417,680 KB
testcase_14 AC 4,194 ms
417,680 KB
testcase_15 AC 3,027 ms
417,680 KB
testcase_16 AC 4,017 ms
417,664 KB
testcase_17 AC 3,245 ms
417,680 KB
testcase_18 AC 3,312 ms
417,676 KB
testcase_19 AC 3,741 ms
417,680 KB
testcase_20 AC 3,306 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)
{
	int L=l,R=(H-x<W-y?H-x:W-y)+1;
	while(R-L>1)
	{
		int M=(L+R)/2;
		int cnt=k;
		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>0)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,1)-f(i,j,K,1);
	}
	cout<<ans<<endl;
}
0