結果
問題 |
No.38 赤青白ブロック
|
ユーザー |
![]() |
提出日時 | 2015-09-29 23:01:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 286 ms / 5,000 ms |
コード長 | 1,050 bytes |
コンパイル時間 | 1,652 ms |
コンパイル使用メモリ | 160,112 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 12:54:59 |
合計ジャッジ時間 | 9,683 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(int i=0; i<(n); i++) int KR, KB; string s; bool ok(string t) { REP(i,t.size()) { if (t[i] == 'R') { if (i + KR < t.size() && t[i+KR] == 'R') return false; if (i - KR >= 0 && t[i-KR] == 'R') return false; } else if (t[i] == 'B') { if (i + KB < t.size() && t[i+KB] == 'B') return false; if (i - KB >= 0 && t[i-KB] == 'B') return false; } } return true; } signed main() { cin>>KR>>KB>>s; int maxc = 0; REP(r,1<<10) REP(b,1<<10) { string t = ""; int ri = 0; int bi = 0; REP(i,s.size()) { if (s[i] == 'R') { if (r & 1<<ri) t += s[i]; ri++; } else if (s[i] == 'B') { if (b & 1<<bi) t += s[i]; bi++; } else { t+= s[i]; } } if (ok(t)) maxc = max(maxc, (int)t.size()); } cout << maxc << endl; return 0; }