結果

問題 No.179 塗り分け
ユーザー hogeover30hogeover30
提出日時 2018-07-10 17:29:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 195 ms / 3,000 ms
コード長 770 bytes
コンパイル時間 1,999 ms
コンパイル使用メモリ 201,640 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 21:02:11
合計ジャッジ時間 5,503 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 12 ms
4,380 KB
testcase_06 AC 5 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 18 ms
4,376 KB
testcase_11 AC 16 ms
4,376 KB
testcase_12 AC 73 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 77 ms
4,376 KB
testcase_19 AC 70 ms
4,376 KB
testcase_20 AC 103 ms
4,376 KB
testcase_21 AC 65 ms
4,380 KB
testcase_22 AC 62 ms
4,380 KB
testcase_23 AC 38 ms
4,376 KB
testcase_24 AC 64 ms
4,376 KB
testcase_25 AC 37 ms
4,376 KB
testcase_26 AC 48 ms
4,376 KB
testcase_27 AC 144 ms
4,376 KB
testcase_28 AC 97 ms
4,376 KB
testcase_29 AC 174 ms
4,376 KB
testcase_30 AC 50 ms
4,380 KB
testcase_31 AC 195 ms
4,380 KB
testcase_32 AC 57 ms
4,376 KB
testcase_33 AC 157 ms
4,380 KB
testcase_34 AC 76 ms
4,376 KB
testcase_35 AC 174 ms
4,376 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 4 ms
4,380 KB
testcase_44 AC 22 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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");
}
0