結果

問題 No.2456 Stamp Art
ユーザー kotatsugamekotatsugame
提出日時 2023-09-01 21:56:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 198 ms / 5,000 ms
コード長 900 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 68,264 KB
実行使用メモリ 38,808 KB
最終ジャッジ日時 2023-09-02 11:17:34
合計ジャッジ時間 5,154 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 151 ms
38,808 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 163 ms
38,744 KB
testcase_07 AC 146 ms
38,752 KB
testcase_08 AC 137 ms
38,756 KB
testcase_09 AC 169 ms
38,748 KB
testcase_10 AC 195 ms
38,756 KB
testcase_11 AC 146 ms
38,748 KB
testcase_12 AC 167 ms
38,784 KB
testcase_13 AC 198 ms
38,752 KB
testcase_14 AC 182 ms
38,804 KB
testcase_15 AC 141 ms
38,744 KB
testcase_16 AC 95 ms
36,936 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 101 ms
30,768 KB
testcase_20 AC 185 ms
38,756 KB
testcase_21 AC 165 ms
38,208 KB
testcase_22 AC 167 ms
38,768 KB
testcase_23 AC 21 ms
30,480 KB
testcase_24 AC 18 ms
19,656 KB
testcase_25 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
using namespace std;
int H,W;
string S[2000];
int MX[2001][2001];
int C[2001][2001];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>H>>W;
	for(int i=0;i<H;i++)cin>>S[i];
	for(int i=H;i--;)for(int j=W;j--;)
	{
		if(S[i][j]=='.')MX[i][j]=0;
		else MX[i][j]=1+min(min(MX[i+1][j],MX[i][j+1]),MX[i+1][j+1]);
	}
	int L=1,R=2222;
	while(R-L>1)
	{
		int K=(L+R)/2;
		for(int i=0;i<=H;i++)for(int j=0;j<=W;j++)C[i][j]=0;
		for(int i=0;i+K<=H;i++)for(int j=0;j+K<=W;j++)if(MX[i][j]>=K)
		{
			C[i][j]++;
			C[i+K][j]--;
			C[i][j+K]--;
			C[i+K][j+K]++;
		}
		for(int i=0;i<=H;i++)for(int j=0;j<W;j++)C[i][j+1]+=C[i][j];
		for(int i=0;i<H;i++)for(int j=0;j<=W;j++)C[i+1][j]+=C[i][j];
		bool ok=true;
		for(int i=0;ok&&i<H;i++)for(int j=0;j<W;j++)if(C[i][j]==0&&S[i][j]=='#')
		{
			ok=false;
			break;
		}
		if(ok)L=K;
		else R=K;
	}
	cout<<L<<endl;
}
0