結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
tossy
|
| 提出日時 | 2017-04-06 00:56:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 88 ms / 3,000 ms |
| コード長 | 1,448 bytes |
| コンパイル時間 | 1,761 ms |
| コンパイル使用メモリ | 174,976 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-23 14:42:11 |
| 合計ジャッジ時間 | 4,115 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#define INF 2147483600
#define long long long // for codeforces
bool solve(){
int h,w;
cin>>h>>w;
vector<string> vec(h);
rep(i,h) cin>>vec[i];
int cnt=0;
rep(i,h)rep(j,w) if(vec[i][j]=='#') cnt++;
if(cnt==0) return false;
if(cnt%2==1) return false;
auto isok = [&](int dx, int dy){
vector<vector<bool>> checked(h,vector<bool>(w,false));
rep(i,h)rep(j,w) if(vec[i][j]=='#' && checked[i][j]==false){
int nx = i+dx, ny = j+dy;
if(nx<0 || ny<0 || nx>=h || ny>=w) return false;
if(vec[nx][ny]=='.') return false;
checked[nx][ny] = true;
}//dbg(mp(dx,dy));
return true;
};
for(int i=-h; i<h; i++) for(int j=-w; j<w; j++) if(!(i==0 && j==0)){
if(isok(i,j)) return true;
}
return false;
}
int main(){
if(solve()) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}
tossy