結果

問題 No.866 レベルKの正方形
ユーザー kotatsugamekotatsugame
提出日時 2019-08-17 03:41:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 719 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 66,236 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-24 23:06:37
合計ジャッジ時間 8,913 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
using namespace std;
int H,W,K;
string s[2000];
int sum[26][2001][2001];
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[c][x+M][y+M]-sum[c][x+M][y]-sum[c][x][y+M]+sum[c][x][y]>0;
			if(cnt<=0)break;
		}
		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 c=0;c<26;c++)for(int i=0;i<H;i++)for(int j=0;j<W;j++)
	{
		sum[c][i+1][j+1]=sum[c][i+1][j]+sum[c][i][j+1]-sum[c][i][j]+(s[i][j]==c+'a');
	}
	long ans=0;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)
	{
		int t=f(i,j,K,1);
		int T=f(i,j,K+1,t>1?t-1:1);
		ans+=T-t;
	}
	cout<<ans<<endl;
}
0