結果
問題 | No.38 赤青白ブロック |
ユーザー |
|
提出日時 | 2014-10-12 23:36:49 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 269 ms / 5,000 ms |
コード長 | 1,637 bytes |
コンパイル時間 | 669 ms |
コンパイル使用メモリ | 70,748 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 12:34:52 |
合計ジャッジ時間 | 8,324 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
#include <iostream> #include <vector> #include <set> #include <queue> #include <algorithm> #include <cstring> #include <cstdio> #include <fstream> #include <sstream> using namespace std; typedef long long ll; int Kr, Kb; bool check(string s){ for(int i=0;i<s.size();i++){ if(s[i] == 'W')continue; if(s[i] == 'R'){ if(i - Kr >= 0)if(s[i - Kr] == 'R')return false; if(i + Kr < s.size())if(s[i + Kr] == 'R')return false; } else { if(i - Kb >= 0)if(s[i - Kb] == 'B')return false; if(i + Kb < s.size())if(s[i + Kb] == 'B')return false; } } return true; } int main(){ cin >> Kr >> Kb; string S; cin >> S; int res = 0; for(int r=0;r<1<<10;r++)for(int b=0;b<1<<10;b++){ int rc = 0; int bc = 0; string s = ""; for(int i=0;i<S.size();i++){ if(S[i] == 'W'){ s += 'W'; continue; } if(S[i] == 'R'){ if((r >> rc) & 1){ } else { s += 'R'; } ++rc; } else { if((b >> bc) & 1){ } else { s += 'B'; } ++bc; } } if(check(s)){ res = max(res, (int)s.size()); } } cout << res << endl; return 0; }