結果
問題 | No.179 塗り分け |
ユーザー |
|
提出日時 | 2015-04-06 00:58:55 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,190 bytes |
コンパイル時間 | 629 ms |
コンパイル使用メモリ | 66,248 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-02 13:39:12 |
合計ジャッジ時間 | 2,027 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 34 WA * 6 |
ソースコード
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <utility> #include <string> using namespace std; vector<string> board; int h, w; bool check(int mx, int my) { if (mx == 0 && my == 0) { return false; } auto paint = board; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (i + my < h && j + mx < w && paint[i][j] == '#') { if (board[i][j] == board[i + my][j + mx]) { paint[i][j] = 'A'; paint[i+my][j+mx] = 'B'; } } } } int na = 0, nb = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { switch (paint[i][j]) { case 'A': na++; break; case 'B': nb++; break; case '#': return false; default: break; } } } return (na == nb); } int main() { cin >> h >> w; board.assign(h, ""); int n = 0; for (int i = 0; i < h; i++) { cin >> board[i]; n += count(board[i].begin(), board[i].end(), '#'); } if (n % 2 == 1) { cout << "NO" << endl; return 0; } int half = n / 2; for (int my = 0; my < h; my++) { for (int mx = 0; mx < w; mx++) { if (check(mx, my)) { cout << "YES" << endl; return 0; } } } cout << "NO" << endl; return 0; }