結果

問題 No.179 塗り分け
ユーザー sugim48sugim48
提出日時 2015-04-05 23:43:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 98 ms / 3,000 ms
コード長 1,511 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 89,900 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 20:35:41
合計ジャッジ時間 2,975 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 6 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 24 ms
4,376 KB
testcase_08 AC 13 ms
4,380 KB
testcase_09 AC 24 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 29 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 30 ms
4,376 KB
testcase_21 AC 28 ms
4,380 KB
testcase_22 AC 26 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 27 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 28 ms
4,376 KB
testcase_27 AC 64 ms
4,380 KB
testcase_28 AC 50 ms
4,380 KB
testcase_29 AC 85 ms
4,376 KB
testcase_30 AC 59 ms
4,376 KB
testcase_31 AC 98 ms
4,376 KB
testcase_32 AC 13 ms
4,376 KB
testcase_33 AC 77 ms
4,376 KB
testcase_34 AC 58 ms
4,376 KB
testcase_35 AC 88 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 3 ms
4,376 KB
testcase_44 AC 12 ms
4,380 KB
testcase_45 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <unordered_map>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v, w; };

ll MOD = 1000000009;
ll _MOD = 1000000009;
double EPS = 1e-10;

bool check(vector<string>& S) {
	int H = S.size(), W = S[0].length();
	for (int dy = 0; dy < H; dy++)
		for (int dx = 0; dx < W; dx++) {
			if (dx == 0 && dy == 0) continue;
			vector<string> s = S;
			bool ok = true;
			int cnt = 0;
			for (int y = 0; y < H; y++)
				for (int x = 0; x < W; x++) {
					if (s[y][x] == '.') continue;
					if (x + dx >= W || y + dy >= H || s[y + dy][x + dx] == '.') {
						ok = false;
						continue;
					}
					cnt++;
					s[y + dy][x + dx] = '.';
				}
			if (ok && cnt) return true;
		}
	return false;
}

int main() {
	int H, W; cin >> H >> W;
	vector<string> S(H);
	for (int y = 0; y < H; y++)
		cin >> S[y];
	if (check(S)) {
		cout << "YES" << endl;
		return 0;
	}
	for (int y = 0; y < H; y++)
		reverse(S[y].begin(), S[y].end());
	if (check(S)) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
}
0