結果
| 問題 | No.38 赤青白ブロック |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-28 03:27:50 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 167 ms / 5,000 ms |
| コード長 | 564 bytes |
| 記録 | |
| コンパイル時間 | 3,248 ms |
| コンパイル使用メモリ | 279,252 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-28 03:27:57 |
| 合計ジャッジ時間 | 6,332 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(void) {
int Kr, Kb;
cin >> Kr >> Kb;
string S;
cin >> S;
auto dfs = [&](auto &&dfs, string s, int i) ->int {
int M = s.size();
if(i == 30) return M;
if(S[i] == 'W') return dfs(dfs, s + 'W', i + 1);
int ans = dfs(dfs, s, i + 1);
if(S[i] == 'R' and (M - Kr < 0 or s[M - Kr] != 'R')) ans = max(ans, dfs(dfs, s + 'R', i + 1));
if(S[i] == 'B' and (M - Kb < 0 or s[M - Kb] != 'B')) ans = max(ans, dfs(dfs, s + 'B', i + 1));
return ans;
};
cout << dfs(dfs, "", 0) << endl;
return 0;
}