結果

問題 No.179 塗り分け
ユーザー btkbtk
提出日時 2015-04-05 23:51:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,015 bytes
コンパイル時間 653 ms
コンパイル使用メモリ 86,032 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 11:19:51
合計ジャッジ時間 4,215 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,940 KB
testcase_02 WA -
testcase_03 AC 2 ms
6,940 KB
testcase_04 RE -
testcase_05 AC 4 ms
6,944 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 1 ms
6,940 KB
testcase_16 RE -
testcase_17 AC 2 ms
6,940 KB
testcase_18 RE -
testcase_19 WA -
testcase_20 AC 15 ms
6,944 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 AC 2 ms
6,940 KB
testcase_37 RE -
testcase_38 AC 2 ms
6,944 KB
testcase_39 AC 1 ms
6,940 KB
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 AC 3 ms
6,940 KB
testcase_44 RE -
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
#define all(b) (b).begin(),(b).end()

#define input_init stringstream ss; string strtoken, token; istringstream is
#define input_line  getline(cin, strtoken);is.str(strtoken);is.clear(istringstream::goodbit)
#define input_token(num) ss.str(""); ss.clear(stringstream::goodbit); getline(is, token, ','); ss << token; ss >> num

#define dir(xx,yy,x,y,i) (xx)=(x)+dir[(i)],(yy)=(y)+dir[(i)+1]

typedef complex<double> P;
typedef vector<P> Poly;

const LL INF = 1 << 30;
const double eps = 1e-8;
const int dir[] = { 0, 1, 0, -1, 0 };

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

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