結果

問題 No.2456 Stamp Art
ユーザー 👑 kmjpkmjp
提出日時 2023-09-01 23:01:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,536 bytes
コンパイル時間 2,460 ms
コンパイル使用メモリ 200,832 KB
実行使用メモリ 133,896 KB
最終ジャッジ日時 2023-09-01 23:02:07
合計ジャッジ時間 9,394 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
129,500 KB
testcase_01 WA -
testcase_02 AC 94 ms
129,476 KB
testcase_03 WA -
testcase_04 AC 58 ms
68,172 KB
testcase_05 AC 84 ms
129,508 KB
testcase_06 AC 266 ms
133,712 KB
testcase_07 AC 286 ms
133,584 KB
testcase_08 AC 281 ms
133,632 KB
testcase_09 AC 302 ms
133,540 KB
testcase_10 AC 295 ms
133,828 KB
testcase_11 AC 265 ms
133,576 KB
testcase_12 AC 282 ms
133,588 KB
testcase_13 WA -
testcase_14 AC 289 ms
133,584 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 59 ms
68,192 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 288 ms
133,588 KB
testcase_23 WA -
testcase_24 AC 159 ms
129,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int H,W;
string S[2020];
int D[4020][4020];
int E[4020][4020];

int ok(int v) {
	if(v>min(H,W)) return 0;
	
	ZERO(E);
	int y,x;
	for(y=v-1;y<H;y++) for(x=v-1;x<W;x++) {
		int num=D[y+1][x+1]-D[y+1-v][x+1]-D[y+1][x+1-v]+D[y+1-v][x+1-v];
		if(num==v*v) E[y+1][x+1]++;
		E[y+1][x+1]+=E[y][x+1]+E[y+1][x]-E[y][x];
	}
	FOR(y,H) FOR(x,W) if(S[y][x]=='#') {
		if(E[y+v][x+v]-E[y][x+v]-E[y+v][x]+E[y][x]==0) return 0;
	}
	return 1;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) {
		cin>>S[y];
		FOR(x,W) {
			D[y+1][x+1]=(S[y][x]=='#');
		}
	}
	
	FOR(y,4010) FOR(x,4010) if(x&&y) D[y][x]+=D[y-1][x]+D[y][x-1]-D[y-1][x-1];
	
	
	int cur=1;
	for(i=10;i>=0;i--) {
		if(ok(cur+(1<<i))) cur+=1<<i;
	}
	cout<<cur<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0