結果
問題 | No.179 塗り分け |
ユーザー |
|
提出日時 | 2020-08-29 14:08:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,171 bytes |
コンパイル時間 | 2,411 ms |
コンパイル使用メモリ | 199,556 KB |
最終ジャッジ日時 | 2025-01-13 20:16:41 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 38 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, const char**)’: main.cpp:13:16: warning: ‘blk_cnt’ may be used uninitialized [-Wmaybe-uninitialized] 13 | blk_cnt++; | ~~~~~~~^~ main.cpp:6:13: note: ‘blk_cnt’ was declared here 6 | int h, w, blk_cnt; | ^~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; int main(int argc, const char *argv[]) { int h, w, blk_cnt; cin >> h >> w; vector<string> grid(h); for (int i = 0; i < h; ++i) { cin >> grid[i]; for (auto c : grid[i]) { if (c == '#') { blk_cnt++; } } } if (blk_cnt == 0) { cout << "YES" << '\n'; return 0; } bool ans = false; for (int i = -h; i <= h && !ans; ++i) { for (int j = -w; j <= w && !ans; ++j) { if (i == 0 && j == 0) { continue; } bool ok = true; vector<vector<bool>> used(h, vector(w, false)); for (int y = 0; y < h && ok; ++y) { for (int x = 0; x < w && ok; ++x) { char c = grid[y][x]; if (c != '#' || used[y][x]) { continue; } int x2 = x + j, y2 = y + i; if (x2 < 0 || x2 >= w || y2 < 0 || y2 >= h || grid[y2][x2] != '#' || used[y2][x2]) { ok = false; break; } used[y2][x2] = true; used[y][x] = true; } } if (ok) { ans = true; } } } cout << (ans ? "YES" : "NO") << '\n'; }