結果

問題 No.179 塗り分け
ユーザー ppp-skyblueppp-skyblue
提出日時 2021-08-08 20:08:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 3,000 ms
コード長 1,588 bytes
コンパイル時間 4,234 ms
コンパイル使用メモリ 231,956 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 20:45:06
合計ジャッジ時間 5,858 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 24 ms
4,348 KB
testcase_09 AC 24 ms
4,348 KB
testcase_10 AC 16 ms
4,348 KB
testcase_11 AC 15 ms
4,348 KB
testcase_12 AC 15 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 11 ms
4,348 KB
testcase_19 AC 10 ms
4,348 KB
testcase_20 AC 10 ms
4,348 KB
testcase_21 AC 19 ms
4,348 KB
testcase_22 AC 21 ms
4,348 KB
testcase_23 AC 16 ms
4,348 KB
testcase_24 AC 18 ms
4,348 KB
testcase_25 AC 19 ms
4,348 KB
testcase_26 AC 11 ms
4,348 KB
testcase_27 AC 13 ms
4,348 KB
testcase_28 AC 11 ms
4,348 KB
testcase_29 AC 13 ms
4,348 KB
testcase_30 AC 13 ms
4,348 KB
testcase_31 AC 12 ms
4,348 KB
testcase_32 AC 14 ms
4,348 KB
testcase_33 AC 13 ms
4,348 KB
testcase_34 AC 12 ms
4,348 KB
testcase_35 AC 13 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 3 ms
4,348 KB
testcase_45 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define frep(i,a,b) for (int i = (a); i <= (b); ++i)
#define all(x) (x).begin(),(x).end()
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define debug(x) cout << #x << ": " << x << endl;
typedef long long ll;
using P = pair<ll,ll>;
using P2 = pair<ll,P>;
using mint = modint1000000007;
#define INF 1001001001
#define LINF (1LL<<60)
#define F first
#define S second
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main() {
  int h, w; cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  vector<string> f;
  bool ans = false, ok;
  int a = 0;
  rep(i, h) rep(j, w) if (s[i][j] == '#') a++;
  if (a == 0) {
    puts("NO");
    return 0;
  }
  for (int i = -h+1; i < h; i++) {
    for (int j = -w+1; j < w; j++) {
      if (i == 0 && j == 0) continue;
      f = s;
      ok = true;
      rep(k,h) {
        rep(l, w) {
          if (f[k][l] == '#') {
            if (k+i < 0 || h-1 < k+i || l+j < 0 || w-1 < l+j || f[k+i][l+j] != '#') {
              ok = false;
              break;
            } else {
              f[k+i][l+j] = '.';
            }
          }
        }
      }
      if (ok) ans = true;
    }
  }
  if (ans) puts("YES");
  else puts("NO");
  
}
0