結果
| 問題 | No.179 塗り分け |
| コンテスト | |
| ユーザー |
yukkuriesu
|
| 提出日時 | 2018-12-05 22:20:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 3,000 ms |
| コード長 | 1,989 bytes |
| コンパイル時間 | 1,275 ms |
| コンパイル使用メモリ | 160,228 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-23 14:53:54 |
| 合計ジャッジ時間 | 2,499 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
#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;
}
yukkuriesu