結果

問題 No.179 塗り分け
ユーザー yukkuriesuyukkuriesu
提出日時 2018-12-05 22:20:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 3,000 ms
コード長 1,989 bytes
コンパイル時間 2,145 ms
コンパイル使用メモリ 146,024 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 21:05:56
合計ジャッジ時間 2,796 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,0,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<"."
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<"."
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"."
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d<<"."
#define da(arr,N){if(isDebugMode){rep(i,N){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N){rep(j,M){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
int h,w;
char m[50][50];

int bc=0;
bool d[100][100];
int tx=-1,ty;
void setd(){
	rep(i,h)
		rep(j,w)
			d[i][j]=(m[i][j]=='#');
	d[ty][tx]=false;
}
void solve(){
	if(bc%2==1) {cout<<"NO"<<endl;return;}
	rep(i,h){
		rep(j,w){
			if(m[i][j]=='#') {
				tx=j,ty=i;
				break;
			}
		}
		if(tx!=-1) break;
	}
	setd();
	rep(i,h)
		rep(j,w){
			if(!d[i][j]) continue;
			d[i][j]=false;
			bool b=false;
			rep(y,h){
				rep(x,w){
					if(d[y][x]){
						if(d[y+i-ty][x+j-tx]){
							d[y][x]=d[y+i-ty][x+j-tx]=false;
						}
						else{b=true;break;}
					}
				}
				if(b) break;
			}
			setd();
			if(!b) {cout<<"YES"<<endl; return;}
		}
	cout<<"NO"<<endl;
}

int main(){
	cin>>h>>w;
	rep(i,h){
		rep(j,w) {
			cin>>m[i][j];
			if(m[i][j]=='#') bc++;
		}
	}
	solve();
	return 0;
}
0