結果

問題 No.2456 Stamp Art
ユーザー 沙耶花沙耶花
提出日時 2023-09-02 21:10:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 502 ms / 5,000 ms
コード長 1,191 bytes
コンパイル時間 5,330 ms
コンパイル使用メモリ 261,756 KB
実行使用メモリ 42,308 KB
最終ジャッジ日時 2023-09-02 21:11:14
合計ジャッジ時間 16,404 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 377 ms
42,228 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 421 ms
42,196 KB
testcase_07 AC 455 ms
42,308 KB
testcase_08 AC 379 ms
42,172 KB
testcase_09 AC 421 ms
42,164 KB
testcase_10 AC 488 ms
42,224 KB
testcase_11 AC 398 ms
42,188 KB
testcase_12 AC 448 ms
42,308 KB
testcase_13 AC 497 ms
42,304 KB
testcase_14 AC 502 ms
42,164 KB
testcase_15 AC 374 ms
42,232 KB
testcase_16 AC 227 ms
22,692 KB
testcase_17 AC 2 ms
4,368 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 250 ms
29,340 KB
testcase_20 AC 439 ms
42,248 KB
testcase_21 AC 416 ms
35,404 KB
testcase_22 AC 441 ms
42,196 KB
testcase_23 AC 21 ms
5,140 KB
testcase_24 AC 35 ms
6,496 KB
testcase_25 AC 1 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001

void Sum(vector<vector<int>> &sum){
	int h = sum.size()-1,w = sum[0].size()-1;
	rep(i,h){
		rep(j,w+1)sum[i+1][j] += sum[i][j];
	}
	rep(i,h+1){
		rep(j,w)sum[i][j+1] += sum[i][j];
	}
	
}

int main(){
	
	int h,w;
	cin>>h>>w;
	vector<string> s(h);
	rep(i,h)cin>>s[i];
	
	vector sum(h+1,vector<int>(w+1));
	rep(i,h){
		rep(j,w){
			if(s[i][j]=='#')sum[i+1][j+1] = 1;
		}
	}
	Sum(sum);
	
	int ok = 1,ng = max(h,w)+1;
	while(ng-ok>1){
		int mid = (ok+ng)/2;
		vector dp(h+1,vector<int>(w+1));
		rep(i,h){
			rep(j,w){
				if(i+mid>h||j+mid>w)continue;
				if(sum[i+mid][j+mid] - sum[i+mid][j] - sum[i][j+mid] + sum[i][j] == mid*mid){
					dp[i][j] ++;
					dp[i+mid][j] --;
					dp[i][j+mid] --;
					dp[i+mid][j+mid] ++;
					
				}
				
			}
		}
		Sum(dp);
		bool f  =true;
		rep(i,h){
			rep(j,w){
				if(s[i][j]=='#'&&dp[i][j]==0){
					f = false;
				}
			}
		}
		
		if(f)ok = mid;
		else ng = mid;
		
	}
	
	cout<<ok<<endl;

		
	return 0;
}
0