結果

問題 No.179 塗り分け
ユーザー rabimea
提出日時 2023-03-13 08:51:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 758 bytes
コンパイル時間 1,752 ms
コンパイル使用メモリ 195,140 KB
最終ジャッジ日時 2025-02-11 10:49:20
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 38 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int N = 55;
string s[N];
bool vis[N][N];

int main() {
	ios::sync_with_stdio(0);
	
	int n, m; cin >> n >> m;
	for(int i = 0; i < n; i ++)
		cin >> s[i];
	
	bool f = 0;
	
	for(int t : {0, 1}) {
		for(int i = 0; i <= n; i ++)
			for(int j = 0; j <= m; j ++) if(i + j > 0) {
				bool t = 1;
				memset(vis, 0, sizeof vis);
				for(int x = 0; x < n; x ++)
					for(int y = 0; y < m; y ++) if(s[x][y] == '#' && !vis[x][y]) {
						vis[x][y] = 1;
						
						int tx = x + i, ty = y + j;
						if(tx >= 0 && tx < n && ty >= 0 && ty < m && s[tx][ty] == '#') {
							vis[tx][ty] = 1;
						} else {
							t = 0;
						}
					}
				f |= t;
			}
	
		reverse(s, s + n);
	}
	
	cout << (f ? "YES" : "NO") << '\n';
}
0