結果

問題 No.179 塗り分け
ユーザー ty70ty70
提出日時 2015-05-23 11:24:34
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,278 bytes
コンパイル時間 705 ms
コンパイル使用メモリ 89,048 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 12:20:16
合計ジャッジ時間 2,042 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define each(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizoef(a))
#define sz(s) (int)((s).size())
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define pb push_back
#define MP(x,y) make_pair((x),(y))
#define NOCOLOR -1
#define RED 0
#define BLUE 1

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

char board[52][52];
int color[52][52];
int H, W;

bool solve (void ){
	int cnt = 0;
	rep (i, H ) rep (j, W ) cnt += (board[i][j] == '#' );
	
	if (cnt == 0 || cnt == 1 ) return false;

	rep (dy, H ){
		rep (dx, W+1 ){
			if (dy == 0 && dx == 0 ) continue;
			memset (color, NOCOLOR, sizeof (color ) );
			bool ok = true;
			rep (i, H ) rep (j, W ){
				if (board[i][j] == '#' && color[i][j] == NOCOLOR ) {
					int nr = i + dy;
					int nc = j + dx;
					if (nr >= H || nc >= W ) {
						ok = false;
						break;
					} // end if
					if (board[nr][nc] == '#' && color[nr][nc] == NOCOLOR ){
						color[i][j] = RED;
						color[nr][nc] = BLUE;
					}else{
						ok = false;
						break;
					} // end if
				} // end if
			} // end rep
			if (ok ) return true;
		} // end rep
	} // end rep
	
	return false;			
}

int main()
{
	memset (board, 0, sizeof (board ) );
	memset (color, 0, sizeof (color ) );
	ios_base::sync_with_stdio(0);
	cin >> H >> W;

	rep (i, H ) rep (j, W ) cin >> board[i][j];

	bool res = solve ();
	cout << (res ? "YES" : "NO" ) << endl;
	
	return 0;
}
0