結果

問題 No.179 塗り分け
ユーザー 👑 OnjoujiTokiOnjoujiToki
提出日時 2023-01-07 02:56:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 136 ms / 3,000 ms
コード長 1,558 bytes
コンパイル時間 1,169 ms
コンパイル使用メモリ 132,804 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-20 19:51:14
合計ジャッジ時間 4,158 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 15 ms
4,376 KB
testcase_11 AC 12 ms
4,380 KB
testcase_12 AC 53 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 26 ms
4,376 KB
testcase_19 AC 23 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 42 ms
4,380 KB
testcase_23 AC 17 ms
4,380 KB
testcase_24 AC 42 ms
4,376 KB
testcase_25 AC 21 ms
4,380 KB
testcase_26 AC 27 ms
4,380 KB
testcase_27 AC 91 ms
4,376 KB
testcase_28 AC 56 ms
4,376 KB
testcase_29 AC 120 ms
4,380 KB
testcase_30 AC 25 ms
4,380 KB
testcase_31 AC 136 ms
4,376 KB
testcase_32 AC 30 ms
4,380 KB
testcase_33 AC 113 ms
4,376 KB
testcase_34 AC 43 ms
4,376 KB
testcase_35 AC 126 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 3 ms
4,380 KB
testcase_44 AC 16 ms
4,380 KB
testcase_45 AC 2 ms
4,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

void solve() {
  int h, w;
  std::cin >> h >> w;
  std::vector<std::string> g(h);
  for (auto& s : g) std::cin >> s;
  int cnt = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (g[i][j] == '#') cnt++;
    }
  }
  if (cnt & 1 or cnt == 0) {
    std::cout << "NO\n";
    return;
  }

  for (int dx = 1 - h; dx < h; dx++) {
    for (int dy = 1 - w; dy < w; dy++) {
      if (!dx and !dy) continue;
      auto t = g;
      int c = 0;
      for (int x = 0; x < h; x++) {
        for (int y = 0; y < w; y++) {
          if (t[x][y] == '#') {
            int nx = x + dx, ny = y + dy;
            if (nx >= 0 and ny >= 0 and nx < h and ny < w and
                t[nx][ny] == '#') {
              t[x][y] = 'R';
              t[nx][ny] = 'B';
              c += 2;
            }
          }
        }
      }
      if (cnt == c) {
        std::cout << "YES" << '\n';
        return;
      }
    }
  }
  std::cout << "NO" << '\n';
}
int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int t = 1;
  // std::cin >> t;
  while (t--) solve();
  // solve();
  return 0;
}
0