結果

問題 No.179 塗り分け
ユーザー imulan
提出日時 2016-02-05 22:32:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,332 bytes
コンパイル時間 1,296 ms
コンパイル使用メモリ 162,840 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-03 03:13:17
合計ジャッジ時間 2,791 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 33 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  int h,w;
  cin >>h >>w;
  std::vector<string> s(h);
  rep(i,h) cin >>s[i];

  int num=0;
  rep(i,h){
    rep(j,w){
      num+=(s[i][j]=='#');
    }
  }

  string ans="NO";

  if(num%2==0){
    bool valid=false;

    rep(y,h){//縦の平行移動幅
      rep(x,w){//横の平行移動幅

        //printf("x,y=%d %d\n",x,y);

        int f[50][50]={0};
        int ct=0;
        rep(i,h){
          rep(j,w){

            if(i+y<h&&j+x<w){
              if(s[i][j]=='#'&&s[i+y][j+x]=='#'){
                if(f[i][j]==0&&f[i+y][j+x]==0){
                  /*
                  printf(" (%d, %d) ->",i,j);
                  printf(" (%d, %d)\n",i+y,j+x);
                  */
                  f[i][j]=1;
                  f[i+y][j+x]=2;
                  ++ct;
                }
              }
            }

          }
        }


        if(ct==num/2){
          valid=true;
          break;
        }
      }
      if(valid) break;
    }

    if(valid) ans="YES";
  }

  std::cout << ans << std::endl;
  return 0;
}
0