結果
問題 | No.38 赤青白ブロック |
ユーザー | atn112323 |
提出日時 | 2016-05-08 13:19:44 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 232 ms / 5,000 ms |
コード長 | 807 bytes |
コンパイル時間 | 526 ms |
コンパイル使用メモリ | 59,672 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-08-25 01:17:11 |
合計ジャッジ時間 | 7,444 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 223 ms
4,380 KB |
testcase_01 | AC | 195 ms
4,384 KB |
testcase_02 | AC | 191 ms
4,380 KB |
testcase_03 | AC | 204 ms
4,380 KB |
testcase_04 | AC | 199 ms
4,380 KB |
testcase_05 | AC | 232 ms
4,384 KB |
testcase_06 | AC | 193 ms
4,380 KB |
testcase_07 | AC | 194 ms
4,380 KB |
testcase_08 | AC | 231 ms
4,384 KB |
testcase_09 | AC | 209 ms
4,380 KB |
testcase_10 | AC | 220 ms
4,380 KB |
testcase_11 | AC | 224 ms
4,384 KB |
testcase_12 | AC | 201 ms
4,384 KB |
testcase_13 | AC | 226 ms
4,380 KB |
testcase_14 | AC | 209 ms
4,384 KB |
testcase_15 | AC | 222 ms
4,384 KB |
testcase_16 | AC | 177 ms
4,384 KB |
testcase_17 | AC | 196 ms
4,384 KB |
testcase_18 | AC | 223 ms
4,380 KB |
testcase_19 | AC | 198 ms
4,380 KB |
testcase_20 | AC | 209 ms
4,380 KB |
testcase_21 | AC | 190 ms
4,380 KB |
testcase_22 | AC | 223 ms
4,384 KB |
testcase_23 | AC | 219 ms
4,380 KB |
testcase_24 | AC | 193 ms
4,384 KB |
testcase_25 | AC | 215 ms
4,384 KB |
testcase_26 | AC | 204 ms
4,380 KB |
ソースコード
#include <algorithm> #include <iostream> #include <string> using namespace std; int Kr, Kb; string S; bool check(const string& str) { for (int i = 0; i < str.length(); i++) { if (str[i] == 'R' && i + Kr < str.length() && str[i + Kr] == 'R') { return false; } if (str[i] == 'B' && i + Kb < str.length() && str[i + Kb] == 'B') { return false; } } return true; } int main() { cin >> Kr >> Kb >> S; int s = 0; for (int i = 0; i < S.length(); i++) { if (S[i] != 'W') { s |= (1 << i); } } int res = 0; int comb = s; do { string str; for (int i = 0; i < S.length(); i++) { if (((comb >> i) & 1) == 0) { str += S[i]; } } if (check(str)) { res = max(res, (int)str.length()); } comb = (comb - 1) & s; } while (comb != s); cout << res << endl; return 0; }