結果

問題 No.38 赤青白ブロック
ユーザー ttkkggwwttkkggww
提出日時 2022-03-30 21:40:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 791 bytes
コンパイル時間 4,022 ms
コンパイル使用メモリ 251,708 KB
最終ジャッジ日時 2025-01-28 13:23:10
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22 WA * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:27:75: warning: ‘r’ may be used uninitialized [-Wmaybe-uninitialized]
   27 |                         int l = i - (t[i]=='R'?r:b),r = i + (t[i]=='R'?r:b);
      |                                                                           ^
main.cpp:27:53: note: ‘r’ was declared here
   27 |                         int l = i - (t[i]=='R'?r:b),r = i + (t[i]=='R'?r:b);
      |                                                     ^

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
int r,b;
string s;

void solve(){
	int ans  =0;
	for(int bit = 0;bit<(1<<20);bit++){
		string t;
		int j = 0;
		for(int i =0;i<30;i++){
			if(s[i]=='W'){
				t.push_back('W');
			}else{
				if((bit>>j)&1){
					t.push_back(s[i]);
				}
				j++;
			}
		}
		bool is = true;
		for(int i  =0;i<t.size();i++){
			if(t[i]=='W')continue;
			int l = i - (t[i]=='R'?r:b),r = i + (t[i]=='R'?r:b);
			if(l>=0&&l<t.size()){
				if(t[i]==t[l])is = false;
			}
			if(r>=0&&r<=t.size()){
				if(t[i]==t[r])is = false;
			}
		}
		if(is)ans = max(ans,(int)t.size());
	}
	cout<<ans<<endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> r >> b;
	cin >> s;
	solve();
}
0