結果

問題 No.38 赤青白ブロック
ユーザー fiordfiord
提出日時 2015-05-31 21:24:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 180 ms / 5,000 ms
コード長 666 bytes
コンパイル時間 688 ms
コンパイル使用メモリ 59,352 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-25 01:05:47
合計ジャッジ時間 6,203 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
4,380 KB
testcase_01 AC 160 ms
4,380 KB
testcase_02 AC 167 ms
4,380 KB
testcase_03 AC 162 ms
4,380 KB
testcase_04 AC 157 ms
4,384 KB
testcase_05 AC 178 ms
4,380 KB
testcase_06 AC 171 ms
4,380 KB
testcase_07 AC 174 ms
4,380 KB
testcase_08 AC 180 ms
4,380 KB
testcase_09 AC 171 ms
4,380 KB
testcase_10 AC 170 ms
4,380 KB
testcase_11 AC 171 ms
4,384 KB
testcase_12 AC 166 ms
4,380 KB
testcase_13 AC 176 ms
4,388 KB
testcase_14 AC 163 ms
4,380 KB
testcase_15 AC 179 ms
4,384 KB
testcase_16 AC 165 ms
4,380 KB
testcase_17 AC 161 ms
4,380 KB
testcase_18 AC 162 ms
4,380 KB
testcase_19 AC 159 ms
4,384 KB
testcase_20 AC 174 ms
4,380 KB
testcase_21 AC 161 ms
4,384 KB
testcase_22 AC 179 ms
4,388 KB
testcase_23 AC 170 ms
4,380 KB
testcase_24 AC 168 ms
4,380 KB
testcase_25 AC 177 ms
4,384 KB
testcase_26 AC 157 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	int kr,kb;
	string s;
	cin>>kr>>kb;
	cin>>s;
	int noW=0;
	for(int i=0;i<30;i++){
		if(s[i]!='W')	noW++;
	}
	int temp[30];
	int ans=0;
	for(int i=0;i<(1<<noW);i++){
		int rb=0,n=0;
		for(int j=0;j<30;j++){
			if(s[j]=='W')	temp[n++]=0;
			else if((i>>(rb++))%2==1){
				if(s[j]=='R')	temp[n++]=1;
				else 	temp[n++]=2;
			}
		}
		bool flag=true;
		for(int j=0;j<n;j++){
			if(temp[j]==1){
				if(j+kr<n&&temp[j+kr]==1)	flag=false;
			}
			else if(temp[j]==2){
				if(j+kb<n&&temp[j+kb]==2)	flag=false;
			}
		}
		if(flag)	ans=max(ans,n);
	}
	cout<<ans<<endl;
	return 0;
}
0