結果
| 問題 |
No.38 赤青白ブロック
|
| コンテスト | |
| ユーザー |
どらら
|
| 提出日時 | 2015-06-17 01:45:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1,287 ms / 5,000 ms |
| コード長 | 1,118 bytes |
| コンパイル時間 | 963 ms |
| コンパイル使用メモリ | 90,148 KB |
| 実行使用メモリ | 34,176 KB |
| 最終ジャッジ日時 | 2024-12-23 12:50:11 |
| 合計ジャッジ時間 | 4,610 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
int ret;
map<string,int> memo;
void solve(int Kr, int Kb, string S){
if(ret > S.length()) return;
if(memo.count(S) > 0) return;
memo[S] = 1;
bool flg = false;
rep(i,S.length()){
if(S[i] == 'R' && i+Kr<S.length() && S[i+Kr]=='R') flg = true;
if(S[i] == 'B' && i+Kb<S.length() && S[i+Kb]=='B') flg = true;
}
if(flg){
rep(i,S.length()){
solve(Kr, Kb, S.substr(0,i) + S.substr(i+1));
}
}else{
ret = max(ret, (int)(S.length()));
}
}
int main(){
int Kr, Kb;
string S;
cin >> Kr >> Kb;
cin >> S;
ret = 3;
solve(Kr, Kb, S);
cout << ret << endl;
return 0;
}
どらら