結果
| 問題 |
No.38 赤青白ブロック
|
| コンテスト | |
| ユーザー |
goodbaton
|
| 提出日時 | 2015-08-06 20:53:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 5,000 ms |
| コード長 | 1,278 bytes |
| コンパイル時間 | 904 ms |
| コンパイル使用メモリ | 81,152 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 12:50:54 |
| 合計ジャッジ時間 | 1,631 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>
typedef long long ll;
using namespace std;
#define mod 1000000009
#define INF 1000000000
#define LLINF 2000000000000000000LL
#define PI 3.1415926536
#define SIZE 101
int kr,kb,ans;
string S;
set<string> memo;
int dfs(string s){
bool f =true;
string ch;
int ret = 0;
if(s.size() <= ans) return 0;
if(memo.find(s)!=memo.end()) return 0;
memo.insert(s);
for(int i=0;i<=s.size();i++){
if(s[i]=='R'){
if(0<=i-kr && s[i-kr]=='R') f = false;
if(i+kr<s.size() && s[i+kr]=='R') f = false;
}
if(s[i]=='B'){
if(0<=i-kb && s[i-kb]=='B') f = false;
if(i+kb<s.size() && s[i+kb]=='B') f = false;
}
}
if(f){
ans = s.size();
return (int)s.size();
}
for(int i=0;i<s.size();i++){
if(s[i]=='W') continue;
ch = s;
ch.erase(ch.begin()+i);
ret = max(dfs(ch),ret);
}
return ret;
}
int main(){
cin >> kr >> kb >> S;
cout << dfs(S) << endl;
return 0;
}
goodbaton