結果
| 問題 |
No.38 赤青白ブロック
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-02-21 11:52:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 559 ms / 5,000 ms |
| コード長 | 1,036 bytes |
| コンパイル時間 | 793 ms |
| コンパイル使用メモリ | 75,128 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-17 10:02:13 |
| 合計ジャッジ時間 | 16,743 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include<iostream>
#include<vector>
using namespace std;
int main(){
int r, b;
string s;
cin >> r >> b >> s;
auto check = [=](string t)->bool{
int n = t.length();
for(int i = 0; i < n; i++){
if(t[i] == 'R'){
if(i-r >= 0 && t[i-r] == 'R') return false;
if(i+r < n && t[i+r] == 'R') return false;
}
if(t[i] == 'B'){
if(i-b >= 0 && t[i-b] == 'B') return false;
if(i+b < n && t[i+b] == 'B') return false;
}
}
return true;
};
vector<int> v;
int ans = 10;
for(int i = 0; i < 30; i++) if(s[i] != 'W') v.push_back(i);
for(int i = 0; i < 1<<20; i++){
vector<bool> use(30, true);
for(int j = 0; j < 20; j++) if((i>>j)&1) use[v[j]] = false;
string t = "";
for(int j = 0; j < 30; j++) if(use[j]) t += s.substr(j,1);
if(check(t)) ans = max(ans, (int)t.length());
}
cout << ans << endl;
return 0;
}