結果

問題 No.179 塗り分け
ユーザー k
提出日時 2020-06-07 06:02:54
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,100 bytes
コンパイル時間 2,553 ms
コンパイル使用メモリ 197,484 KB
最終ジャッジ日時 2025-01-10 23:39:26
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 35 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const double PI = acos(-1);

int h, w;
vector<string> bd;

bool check() {
  int c = 0;
  REP (i, h) REP (j, w) c += bd[i][j] == '#';
  if (!c)
    return false;
  
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      int r = 0, b = 0;
      vector<string> tmp = bd;
      for (int i = 0; i+y < h; i++) {
        for (int j = 0; j+x < w; j++) {
          if (tmp[i][j] == '#') {
            if (tmp[i+y][j+x] == '#' && x+y > 0) {
              tmp[i][j] = 'r';
              tmp[i+y][j+x] = 'b';
              ++r, ++b;
            } 
          }
        }
      }
      if (r == b && r + b == c) {
        return true;
      }
    }
  }
  return false;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> h >> w;
  REP (i, h) {
    string s; cin >> s;
    bd.push_back(s);
  }

  if (check())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}
0