結果
| 問題 |
No.38 赤青白ブロック
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2019-02-22 21:16:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 404 ms / 5,000 ms |
| コード長 | 1,163 bytes |
| コンパイル時間 | 1,785 ms |
| コンパイル使用メモリ | 197,492 KB |
| 最終ジャッジ日時 | 2025-01-06 21:34:42 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//INSERT ABOVE HERE
signed main(){
int p,q;
cin>>p>>q;
string s;
cin>>s;
vector<int> rs(10),bs(10);
for(int i=0,r=0,b=0;i<30;i++){
if(s[i]=='R') rs[r++]=i;
if(s[i]=='B') bs[b++]=i;
}
int ans=0;
for(int r=0;r<(1<<10);r++){
for(int b=0;b<(1<<10);b++){
vector<int> used(30,0);
for(int i=0,j=0;i<30;i++){
if(s[i]!='R') continue;
if((r>>j)&1) used[rs[j]]=1;
j++;
}
for(int i=0,j=0;i<30;i++){
if(s[i]!='B') continue;
if((b>>j)&1) used[bs[j]]=1;
j++;
}
for(int i=0;i<30;i++)
if(s[i]=='W') used[i]=1;
string t;
for(int i=0;i<30;i++)
if(used[i]) t+=s[i];
int m=t.size();
int flg=1;
for(int i=0;i<m;i++){
if(t[i]=='R'&&i>=p&&t[i-p]=='R') flg=0;
if(t[i]=='B'&&i>=q&&t[i-q]=='B') flg=0;
}
if(flg) chmax(ans,m);
}
}
cout<<ans<<endl;
return 0;
}
beet