結果

問題 No.38 赤青白ブロック
ユーザー maine_honzukimaine_honzuki
提出日時 2020-05-06 21:48:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 292 ms / 5,000 ms
コード長 1,636 bytes
コンパイル時間 1,486 ms
コンパイル使用メモリ 165,080 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 07:34:12
合計ジャッジ時間 10,093 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 270 ms
4,376 KB
testcase_01 AC 225 ms
4,380 KB
testcase_02 AC 225 ms
4,380 KB
testcase_03 AC 251 ms
4,376 KB
testcase_04 AC 233 ms
4,376 KB
testcase_05 AC 275 ms
4,376 KB
testcase_06 AC 223 ms
4,380 KB
testcase_07 AC 221 ms
4,380 KB
testcase_08 AC 285 ms
4,376 KB
testcase_09 AC 243 ms
4,380 KB
testcase_10 AC 287 ms
4,376 KB
testcase_11 AC 284 ms
4,376 KB
testcase_12 AC 251 ms
4,376 KB
testcase_13 AC 280 ms
4,376 KB
testcase_14 AC 250 ms
4,376 KB
testcase_15 AC 258 ms
4,380 KB
testcase_16 AC 213 ms
4,384 KB
testcase_17 AC 235 ms
4,376 KB
testcase_18 AC 255 ms
4,376 KB
testcase_19 AC 235 ms
4,380 KB
testcase_20 AC 239 ms
4,380 KB
testcase_21 AC 208 ms
4,376 KB
testcase_22 AC 226 ms
4,376 KB
testcase_23 AC 292 ms
4,376 KB
testcase_24 AC 222 ms
4,376 KB
testcase_25 AC 259 ms
4,380 KB
testcase_26 AC 241 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int Kr, Kb;
    string S;
    cin >> Kr >> Kb >> S;

    int ans = 0;
    for (int bit_r = 0; bit_r < (1 << 10); bit_r++) {
        for (int bit_b = 0; bit_b < (1 << 10); bit_b++) {
            int now_r = 0, now_b = 0;
            string s;
            for (auto& c : S) {
                if (c == 'R') {
                    if (!(bit_r & 1 << now_r))
                        s.push_back('R');
                    now_r++;
                } else if (c == 'B') {
                    if (!(bit_b & 1 << now_b))
                        s.push_back('B');
                    now_b++;
                } else
                    s.push_back('W');
            }

            bool flag = true;
            for (int i = 0; i < 30; i++) {
                int c = s[i];
                if (c == 'R') {
                    if (i - Kr >= 0) {
                        if (s[i - Kr] == 'R')
                            flag = false;
                    }
                    if (i + Kr < 30)
                        if (s[i + Kr] == 'R')
                            flag = false;
                }
                if (c == 'B') {
                    if (i - Kb >= 0) {
                        if (s[i - Kb] == 'B')
                            flag = false;
                    }
                    if (i + Kb < 30)
                        if (s[i + Kb] == 'B')
                            flag = false;
                }
                if (!flag)
                    break;
            }
            if (flag) ans = max(ans, int(s.size()));
        }
    }
    cout << ans << endl;
}
0