結果

問題 No.179 塗り分け
ユーザー btkbtk
提出日時 2015-04-06 00:36:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,576 bytes
コンパイル時間 885 ms
コンパイル使用メモリ 85,640 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 11:30:06
合計ジャッジ時間 2,627 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 4 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 WA -
testcase_08 AC 11 ms
6,944 KB
testcase_09 WA -
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 18 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 WA -
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 16 ms
6,944 KB
testcase_21 AC 14 ms
6,940 KB
testcase_22 AC 13 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 13 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 WA -
testcase_27 AC 33 ms
6,940 KB
testcase_28 WA -
testcase_29 AC 43 ms
6,940 KB
testcase_30 WA -
testcase_31 AC 46 ms
6,940 KB
testcase_32 AC 15 ms
6,940 KB
testcase_33 AC 41 ms
6,940 KB
testcase_34 WA -
testcase_35 AC 44 ms
6,940 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 1 ms
6,944 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 7 ms
6,940 KB
testcase_45 AC 2 ms
6,940 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 == 0){
		cout << "YES" << endl;
		return 0;
	}
	board();
	rT(i,h)
		rT(j, 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 )
					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