結果

問題 No.38 赤青白ブロック
ユーザー h_nosonh_noson
提出日時 2016-04-29 19:22:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 274 ms / 5,000 ms
コード長 888 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 63,744 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 01:15:15
合計ジャッジ時間 4,692 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 152 ms
4,376 KB
testcase_01 AC 57 ms
4,376 KB
testcase_02 AC 35 ms
4,380 KB
testcase_03 AC 123 ms
4,380 KB
testcase_04 AC 123 ms
4,376 KB
testcase_05 AC 182 ms
4,380 KB
testcase_06 AC 31 ms
4,380 KB
testcase_07 AC 34 ms
4,384 KB
testcase_08 AC 110 ms
4,376 KB
testcase_09 AC 31 ms
4,384 KB
testcase_10 AC 173 ms
4,376 KB
testcase_11 AC 162 ms
4,380 KB
testcase_12 AC 105 ms
4,376 KB
testcase_13 AC 274 ms
4,380 KB
testcase_14 AC 87 ms
4,380 KB
testcase_15 AC 108 ms
4,380 KB
testcase_16 AC 15 ms
4,376 KB
testcase_17 AC 62 ms
4,376 KB
testcase_18 AC 137 ms
4,380 KB
testcase_19 AC 109 ms
4,380 KB
testcase_20 AC 70 ms
4,380 KB
testcase_21 AC 27 ms
4,380 KB
testcase_22 AC 11 ms
4,376 KB
testcase_23 AC 217 ms
4,376 KB
testcase_24 AC 37 ms
4,380 KB
testcase_25 AC 93 ms
4,376 KB
testcase_26 AC 84 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000

typedef long long ll;

int kr, kb;
string s;

int dfs(string ans, int n) {
    if (n == 30)
        return ans.size();
    else if (s[n] == 'R') {
        if (kr > ans.size() || ans[ans.size()-kr] != 'R')
            return max(dfs(ans+s[n],n+1),dfs(ans,n+1));
        else
            return dfs(ans,n+1);
    }
    else if (s[n] == 'B') {
        if (kb > ans.size() || ans[ans.size()-kb] != 'B')
            return max(dfs(ans+s[n],n+1),dfs(ans,n+1));
        else
            return dfs(ans,n+1);
    }
    else
        return dfs(ans+s[n],n+1);
}

int main() {
    cin >> kr >> kb >> s;
    cout << dfs("",0) << endl;
    return 0;
}
0