結果

問題 No.179 塗り分け
ユーザー lapilapi
提出日時 2019-08-11 15:03:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,620 bytes
コンパイル時間 964 ms
コンパイル使用メモリ 104,144 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 17:08:37
合計ジャッジ時間 2,811 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,356 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 WA -
testcase_24 AC 2 ms
4,348 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,352 KB
testcase_28 WA -
testcase_29 AC 2 ms
4,352 KB
testcase_30 WA -
testcase_31 AC 2 ms
4,352 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 ms
4,352 KB
testcase_34 WA -
testcase_35 AC 2 ms
4,352 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 1 ms
4,348 KB
testcase_38 AC 2 ms
4,352 KB
testcase_39 AC 2 ms
4,352 KB
testcase_40 AC 1 ms
4,352 KB
testcase_41 AC 1 ms
4,352 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 1 ms
4,352 KB
testcase_44 AC 2 ms
4,352 KB
testcase_45 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

bool white[59][59];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int H, W; cin >> H >> W;
	P start; start.first = -1; start.second = -1;

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			char c; cin >> c;
			if (c == '.') white[i][j] = true;
			if (start.first == -1) {
				start.first = i;
				start.second = j;
			}
		}
	}

	for (int dx = 0; dx <= H - start.first; dx++) {
		for (int dy = 0; dy <= W - start.second; dy++) {
			if ((dx>0 || dy > 0)&& !white[start.first + dx][start.second + dy]) {

				bool field[59][59];
				for (int i = 1; i <= H; i++) {
					for (int j = 1; j <= W; j++) field[i][j] = white[i][j];
				}
				bool flag = true;

				for (int i = 1; i <= H && flag; i++) {
					for (int j = 1; j <= W && flag; j++) {
						if (!field[i][j]) { // 元が黒で
							if (i + dx > H || j + dy > W) flag = false;
							else {
								if (field[i + dx][j + dy]) {// 平行移動先が白
									flag = false;
								}
								else { // 平行移動先も黒
									field[i][j] = true;
									field[i + dx][j + dy] = true;
								}
							}
						}
					}
				}

				if (flag) {
					cout << "YES" << endl;
					return 0;
				}

			}
		}
	}
	cout << "NO" << endl;

	return 0;
}
0