結果

問題 No.179 塗り分け
ユーザー tossytossy
提出日時 2017-04-06 00:56:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,448 bytes
コンパイル時間 1,882 ms
コンパイル使用メモリ 171,276 KB
実行使用メモリ 17,344 KB
最終ジャッジ日時 2024-04-14 06:22:51
合計ジャッジ時間 10,611 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#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; h++) 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;
}
0