結果

問題 No.179 塗り分け
ユーザー minami
提出日時 2019-03-26 16:13:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,315 bytes
コンパイル時間 1,850 ms
コンパイル使用メモリ 176,132 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-11 01:27:50
合計ジャッジ時間 3,802 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 34 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W; cin >> H >> W;
	vector<vector<char>> S(H, vector<char>(W));
	rep(i, 0, H) rep(j, 0, W) { cin >> S[i][j]; }

	auto inrange = [&](int i, int j) { return i >= 0 && i < H && j >= 0 && j < W; };

	rep(di, 0, H)rep(dj, 0, W) {
		if (di == 0 && dj == 0)continue;
		vector<vector<bool>> used(H, vector<bool>(W));
		bool ok = true;
		rep(i, 0, H)rep(j, 0, W) {
			if (used[i][j])continue;
			if (S[i][j] == '.')continue;
			used[i][j] = true;
			int ni = i + di, nj = j + dj;
			if (!inrange(ni, nj) || S[ni][nj] == '.') {
				ok = false;
				break;
			}
			used[ni][nj] = true;
		}
		if (ok) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;

	return 0;
}
0