結果
| 問題 |
No.38 赤青白ブロック
|
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2015-06-16 00:45:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 102 ms / 5,000 ms |
| コード長 | 921 bytes |
| コンパイル時間 | 629 ms |
| コンパイル使用メモリ | 63,136 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 12:49:06 |
| 合計ジャッジ時間 | 3,726 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
string s;
getline(cin, s);
stringstream ss(s);
int Kr, Kb;
ss >> Kr >> Kb;
getline(cin, s);
int rb = 0;
int cnt[256] = {};
for (char c : s) {
cnt[c] += 1;
}
int m = 1 << (cnt['R'] + cnt['B']);
int ans = 0;
for (int b = 0; b < m; ++b) {
char w[32];
int bpos = 0, wpos = 0;
bool f = true;
for (char c : s) {
if (c == 'W') {
w[wpos++] = c;
} else {
if ((1 << bpos) & b) {
if (c == 'R') {
if (wpos >= Kr && w[wpos - Kr] == 'R') {
f = false;
break;
}
} else {
if (wpos >= Kb && w[wpos - Kb] == 'B') {
f = false;
break;
}
}
w[wpos++] = c;
}
++bpos;
}
}
if (f) {
ans = max(ans, wpos);
}
}
cout << ans << endl;
return 0;
}
hotpepsi