結果
問題 | No.38 赤青白ブロック |
ユーザー |
![]() |
提出日時 | 2015-05-31 21:24:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 158 ms / 5,000 ms |
コード長 | 666 bytes |
コンパイル時間 | 547 ms |
コンパイル使用メモリ | 57,976 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 12:47:48 |
合計ジャッジ時間 | 5,431 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
#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; }