結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-12 14:37:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 91 ms / 3,000 ms |
| コード長 | 1,501 bytes |
| コンパイル時間 | 1,428 ms |
| コンパイル使用メモリ | 79,224 KB |
| 最終ジャッジ日時 | 2025-01-09 17:41:52 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
void solve() {
int h, w;
std::cin >> h >> w;
std::vector<std::string> ss(h);
for (auto& s : ss) std::cin >> s;
for (int q = 0; q < 2; ++q) {
for (int dx = 0; dx < h; ++dx) {
for (int dy = 0; dy < w; ++dy) {
auto ts = ss;
bool judge = true;
for (int x = 0; x < h; ++x) {
for (int y = 0; y < w; ++y) {
if (ts[x][y] != '#') continue;
ts[x][y] = 'O';
int nx = x + dx,
ny = y + dy;
if (nx >= h || ny >= w ||
ts[nx][ny] != '#') {
judge = false;
} else {
ts[nx][ny] = 'X';
}
}
}
if (judge) {
if (q) std::reverse(ts.begin(), ts.end());
for (auto& t : ts) std::cerr << t << std::endl;
std::cout << (dx == 0 && dy == 0 ? "NO" : "YES")
<< std::endl;
return;
}
}
}
std::reverse(ss.begin(), ss.end());
}
std::cout << "NO" << std::endl;
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
solve();
return 0;
}