結果
問題 | No.179 塗り分け |
ユーザー |
![]() |
提出日時 | 2018-07-10 17:29:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 186 ms / 3,000 ms |
コード長 | 770 bytes |
コンパイル時間 | 1,895 ms |
コンパイル使用メモリ | 198,524 KB |
最終ジャッジ日時 | 2025-01-06 11:55:43 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int H, W; cin>>H>>W; vector<string> S(H); int N=0; for(auto& e: S) { cin>>e; N+=count(begin(e), end(e), '#'); } if (N==0) return !printf("NO\n"); #define REP(i, a, b) for(int i=a; i<b; ++i) REP(r, -H, H) REP(c, -W, W) if (c|r) { auto T=S; int red=0, blue=0; REP(i, 0, H) REP(j, 0, W) { if (!(T[i][j]=='#' && 0<=i+r && i+r<H && 0<=j+c && j+c<W)) continue; if (T[i][j]==T[i+r][j+c]) { T[i][j]=0; T[i+r][j+c]=1; ++red; ++blue; } } if (red==blue && N==red+blue) return !printf("YES\n"); } puts("NO"); }