結果

問題 No.38 赤青白ブロック
ユーザー cielciel
提出日時 2014-12-02 03:14:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 196 ms / 5,000 ms
コード長 589 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 53,212 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 00:58:13
合計ジャッジ時間 5,789 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 193 ms
4,376 KB
testcase_01 AC 122 ms
4,376 KB
testcase_02 AC 149 ms
4,380 KB
testcase_03 AC 152 ms
4,376 KB
testcase_04 AC 109 ms
4,380 KB
testcase_05 AC 184 ms
4,380 KB
testcase_06 AC 112 ms
4,380 KB
testcase_07 AC 114 ms
4,376 KB
testcase_08 AC 196 ms
4,380 KB
testcase_09 AC 118 ms
4,376 KB
testcase_10 AC 196 ms
4,380 KB
testcase_11 AC 185 ms
4,376 KB
testcase_12 AC 165 ms
4,376 KB
testcase_13 AC 192 ms
4,376 KB
testcase_14 AC 155 ms
4,376 KB
testcase_15 AC 193 ms
4,380 KB
testcase_16 AC 63 ms
4,380 KB
testcase_17 AC 138 ms
4,376 KB
testcase_18 AC 184 ms
4,376 KB
testcase_19 AC 172 ms
4,376 KB
testcase_20 AC 123 ms
4,380 KB
testcase_21 AC 121 ms
4,380 KB
testcase_22 AC 118 ms
4,376 KB
testcase_23 AC 194 ms
4,376 KB
testcase_24 AC 92 ms
4,380 KB
testcase_25 AC 168 ms
4,380 KB
testcase_26 AC 174 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;
int main(){
	int Kr,Kb,R=0;
	string s;
	cin>>Kr>>Kb>>s;
	for(int i=0;i<1<<10;i++)for(int j=0;j<1<<10;j++){
		string t;
		int k=0,r=0,b=0;
		for(;k<s.size();k++){
			if(s[k]=='R'){
				if(i&(1<<r)){
					if(t.size()>=Kr&&t[t.size()-Kr]=='R')break;
					t+='R';
				}
				r++;
			}else if(s[k]=='B'){
				if(j&(1<<b)){
					if(t.size()>=Kb&&t[t.size()-Kb]=='B')break;
					t+='B';
				}
				b++;
			}else if(s[k]=='W'){
				t+='W';
			}
		}
		if(k==s.size())R=max(R,(int)t.size());
	}
	cout<<R<<endl;
}
0