結果

問題 No.179 塗り分け
ユーザー omuomu
提出日時 2015-04-06 00:56:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 929 ms / 3,000 ms
コード長 2,380 bytes
コンパイル時間 647 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-30 20:37:19
合計ジャッジ時間 9,598 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 34 ms
4,380 KB
testcase_06 AC 10 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 38 ms
4,376 KB
testcase_09 AC 39 ms
4,376 KB
testcase_10 AC 165 ms
4,380 KB
testcase_11 AC 138 ms
4,380 KB
testcase_12 AC 349 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 149 ms
4,376 KB
testcase_19 AC 138 ms
4,380 KB
testcase_20 AC 251 ms
4,380 KB
testcase_21 AC 197 ms
4,380 KB
testcase_22 AC 204 ms
4,376 KB
testcase_23 AC 107 ms
4,376 KB
testcase_24 AC 168 ms
4,376 KB
testcase_25 AC 87 ms
4,380 KB
testcase_26 AC 171 ms
4,380 KB
testcase_27 AC 566 ms
4,384 KB
testcase_28 AC 453 ms
4,376 KB
testcase_29 AC 785 ms
4,380 KB
testcase_30 AC 284 ms
4,380 KB
testcase_31 AC 929 ms
4,376 KB
testcase_32 AC 265 ms
4,376 KB
testcase_33 AC 671 ms
4,380 KB
testcase_34 AC 380 ms
4,380 KB
testcase_35 AC 762 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 9 ms
4,380 KB
testcase_44 AC 64 ms
4,376 KB
testcase_45 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

#define rep(i,n)  for(int (i) = 0;(i) < (n);(i)++)
#define clr(a) memset((a), 0 ,sizeof(a))
#define mclr(a) memset((a), -1 ,sizeof(a))
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (sizeof(a))
#define Fill(a,v) fill((int*)a,(int*)(a+(SZ(a)/SZ(*(a)))),v)
bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
const int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
const int mod = 1000000007;
const int INF = 2147483647;


int main()
{
	int h,w;
	cin >> h >> w;
	string s[101];
	rep(i, h){
		cin >> s[i];
	}
	rep(i, h){
		rep(j, w){
			if (s[i][j] == '.'){
				if (i == h - 1 && j == w - 1)
				{
					cout << "NO" << endl;
					return 0;
				}
			}
			else
			goto SINITAI;
		}
	}

	SINITAI:;

	for (int k = -h*2; k < h*2; k++){
		for (int l = -w*2; l < w*2; l++){
			if (!(k == 0 && l == 0)){
				bool f[51][51]; clr(f);
				rep(i, h){
					rep(j, w){
						if (s[i][j] == '.')
							f[i][j] = true;
					}
				}

				for (int i = 0; i < h; i++){
					for (int j = 0; j < w; j++){


						if (s[i][j] == '#' && !f[i][j]){

							if (cheak(i + k, j + l, h, w)){
								if (s[i + k][j + l] == '#' && !f[i + k][j + l]){
									f[i][j] = true;
									f[i + k][j + l] = true;
									continue;
								}
							}

							if (cheak(i - k, j - l, h, w)){
								if (s[i - k][j - l] == '#' && !f[i - k][j - l]){
									f[i][j] = true;
									f[i - k][j - l] = true;
									continue;
								}
							}
						}
					}
				}

				rep(i, h){
					rep(j, w){
						if (f[i][j]){
							if (i == h - 1 && j == w - 1){
								cout << "YES" << endl;
								return 0;
							}
						}
						else
							goto LABEL;
					}
				}

			LABEL:;
			}
		}
	}



	
	cout << "NO" << endl;

	return 0;
}
0