結果

問題 No.179 塗り分け
ユーザー alpha_virginis
提出日時 2016-03-10 20:31:55
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,165 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 66,916 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-03 03:17:35
合計ジャッジ時間 1,841 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 34 WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:39:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |     scanf("%s", field[i]);
      |     ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #

#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <cassert>

int H, W;
char field[64][64];
bool checked[64][64];

bool judge(int dr, int dc) {
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      checked[i][j] = false;
    }
  }
  for(int r = 0; r < H; ++r) {
    for(int c = 0; c < W; ++c) {
      if( field[r][c] != '#' ) continue;
      if( checked[r][c] ) continue;
      int nr = r + dr;
      int nc = c + dc;
      if( not ( 0 <= nr and nr < H and 0 <= nc and nc < W ) ) return false;
      if( field[r+dr][c+dc] != '#' ) return false;
      checked[r+dr][c+dc] = true;
    }
  }
  return true;
}

int main() {
  // step 1
  std::cin >> H >> W;
  for(int i = 0; i < H; ++i) {
    scanf("%s", field[i]);
  }

  // step 2
  bool res = false;
  [&](){
    for(int dr = 0; dr < H; ++dr) {
      for(int dc = 0; dc < W; ++dc) {
        if( dr == 0 and dc == 0 ) continue;
        if( judge(dr, dc) ) {
          res = true;
          return;
        }
      }
    }
  }();
  std::cout << (res ? "YES" : "NO") << std::endl;  
  
  return 0;
}
0