結果

問題 No.179 塗り分け
ユーザー btkbtk
提出日時 2015-04-06 00:53:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 157 ms / 3,000 ms
コード長 1,610 bytes
コンパイル時間 681 ms
コンパイル使用メモリ 84,700 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 20:36:55
合計ジャッジ時間 3,758 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 10 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 59 ms
4,380 KB
testcase_09 AC 59 ms
4,376 KB
testcase_10 AC 43 ms
4,380 KB
testcase_11 AC 37 ms
4,376 KB
testcase_12 AC 75 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 37 ms
4,380 KB
testcase_19 AC 34 ms
4,376 KB
testcase_20 AC 66 ms
4,380 KB
testcase_21 AC 65 ms
4,376 KB
testcase_22 AC 63 ms
4,380 KB
testcase_23 AC 35 ms
4,380 KB
testcase_24 AC 62 ms
4,376 KB
testcase_25 AC 32 ms
4,376 KB
testcase_26 AC 44 ms
4,376 KB
testcase_27 AC 104 ms
4,376 KB
testcase_28 AC 63 ms
4,380 KB
testcase_29 AC 135 ms
4,376 KB
testcase_30 AC 92 ms
4,380 KB
testcase_31 AC 157 ms
4,376 KB
testcase_32 AC 75 ms
4,380 KB
testcase_33 AC 124 ms
4,376 KB
testcase_34 AC 79 ms
4,380 KB
testcase_35 AC 142 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 1 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 17 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<utility>
#include<complex>

using namespace std;

#define reE(i,a,b) for(auto (i)=(a);(i)<=(b);(i)++)
#define rE(i,b) reE(i,0,b)
#define reT(i,a,b) for(auto (i)=(a);(i)<(b);(i)++)
#define rT(i,b) reT(i,0,b)
#define rep(i,a,b) reE(i,a,b);
#define rev(i,a,b) for(auto (i)=(b)-1;(i)>=(a);(i)--)
#define fe(i,b) for (auto &(x):b);
#define itr(i,b) for(auto (i)=(b).begin();(i)!=(b).end();++(i))
#define rti(i,b) for(auto (i)=(b).rbegin();(i)!=(b).rend();++(i))
#define LL long long


int bw[100][100];
int c[100][100];
string str;
int h, w;
bool board(){
	int r = 0, b = 0;
	rT(i, h)
		rT(j, w){
		if (c[i][j] == 1)r++;
		else if (c[i][j] == 2)b ++;
		c[i][j] = bw[i][j];
	}
	return (r>0&&b>0&&r==b);
}

int main(void){
	cin >> h >> w;
	int t=0;
	rT(i, h){
		cin >> str;
		rT(j, w){
			if (str[j] == '.')bw[i][j] = -1;
			else bw[i][j] = 0,t++;
		}
	}
	if (t <2){
		cout << "NO" << endl;
		return 0;
	}
	board();
	reT(i,-h+1,h)
		reT(j,-w+1 ,w){
		if (i == 0 && j == 0)continue;
		bool flag = true;
		rT(x, h)
			rT(y, w){
			if (c[x][y] == 0){
				c[x][y] = 1;
				if (x + i >= h || y + j >= w || x + i < 0 || y + j <0 )
					flag = false;
				else if (c[x + i][y + j] != 0)
					flag = false;
				else
				c[x + i][y + j] = 2;
			}
		}
		flag &= board();
		if (flag){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return(0);
}
0