結果

問題 No.38 赤青白ブロック
ユーザー mamekinmamekin
提出日時 2015-01-14 21:55:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 250 ms / 5,000 ms
コード長 1,166 bytes
コンパイル時間 617 ms
コンパイル使用メモリ 90,016 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 00:59:11
合計ジャッジ時間 8,275 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 237 ms
4,376 KB
testcase_01 AC 225 ms
4,376 KB
testcase_02 AC 235 ms
4,376 KB
testcase_03 AC 223 ms
4,376 KB
testcase_04 AC 227 ms
4,376 KB
testcase_05 AC 240 ms
4,376 KB
testcase_06 AC 239 ms
4,376 KB
testcase_07 AC 242 ms
4,380 KB
testcase_08 AC 237 ms
4,380 KB
testcase_09 AC 239 ms
4,376 KB
testcase_10 AC 227 ms
4,380 KB
testcase_11 AC 230 ms
4,380 KB
testcase_12 AC 243 ms
4,376 KB
testcase_13 AC 238 ms
4,380 KB
testcase_14 AC 241 ms
4,376 KB
testcase_15 AC 241 ms
4,376 KB
testcase_16 AC 230 ms
4,380 KB
testcase_17 AC 233 ms
4,380 KB
testcase_18 AC 233 ms
4,380 KB
testcase_19 AC 218 ms
4,380 KB
testcase_20 AC 242 ms
4,380 KB
testcase_21 AC 235 ms
4,376 KB
testcase_22 AC 247 ms
4,376 KB
testcase_23 AC 232 ms
4,380 KB
testcase_24 AC 237 ms
4,376 KB
testcase_25 AC 250 ms
4,376 KB
testcase_26 AC 227 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int kr, kb;
    string s;
    cin >> kr >> kb >> s;

    int ret = 0;
    for(int i=0; i<(1<<20); ++i){
        bitset<32> bs(i);
        string t;
        int k = 0;
        for(int j=0; j<30; ++j){
            if(s[j] == 'W'){
                t += 'W';
            }
            else{
                if(bs[k])
                    t += s[j];
                ++ k;
            }
        }

        bool ok = true;
        for(unsigned j=0; j<t.size(); ++j){
            if(t[j] == 'R' && j + kr < t.size() && t[j+kr] == 'R')
                ok = false;
            if(t[j] == 'B' && j + kb < t.size() && t[j+kb] == 'B')
                ok = false;
        }
        if(ok)
            ret = max<int>(ret, t.size());
    }
    cout << ret << endl;

    return 0;
}
0