結果

問題 No.38 赤青白ブロック
ユーザー not_522not_522
提出日時 2015-07-16 21:42:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 624 ms / 5,000 ms
コード長 768 bytes
コンパイル時間 1,308 ms
コンパイル使用メモリ 156,128 KB
実行使用メモリ 54,612 KB
最終ジャッジ日時 2023-08-25 01:08:03
合計ジャッジ時間 8,673 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
17,092 KB
testcase_01 AC 52 ms
9,660 KB
testcase_02 AC 242 ms
32,388 KB
testcase_03 AC 268 ms
27,508 KB
testcase_04 AC 81 ms
8,784 KB
testcase_05 AC 154 ms
17,376 KB
testcase_06 AC 305 ms
36,336 KB
testcase_07 AC 407 ms
53,800 KB
testcase_08 AC 499 ms
49,096 KB
testcase_09 AC 230 ms
27,120 KB
testcase_10 AC 300 ms
29,360 KB
testcase_11 AC 440 ms
47,984 KB
testcase_12 AC 311 ms
30,424 KB
testcase_13 AC 281 ms
19,676 KB
testcase_14 AC 222 ms
22,968 KB
testcase_15 AC 216 ms
32,708 KB
testcase_16 AC 54 ms
9,096 KB
testcase_17 AC 115 ms
19,040 KB
testcase_18 AC 135 ms
18,440 KB
testcase_19 AC 59 ms
10,196 KB
testcase_20 AC 153 ms
19,876 KB
testcase_21 AC 170 ms
23,564 KB
testcase_22 AC 38 ms
6,808 KB
testcase_23 AC 199 ms
19,500 KB
testcase_24 AC 624 ms
54,612 KB
testcase_25 AC 387 ms
46,588 KB
testcase_26 AC 64 ms
12,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  int kr, kb;
  string s;
  cin >> kr >> kb >> s;
  set<string> s1{""}, s2;
  for (char c : s) {
    for (auto s : s1) {
      if (c != 'W') s2.insert(s);
      s2.insert(s + c);
    }
    s1 = s2;
    s2.clear();
  }
  int res = 0;
  for (auto s : s1) {
    bool f = true;
    for (int i = 0; i < (int)s.size(); ++i) {
      if (s[i] == 'R') {
        if (0 <= i - kr && s[i - kr] == 'R') f = false;
        if (i + kr < (int)s.size()&& s[i + kr] == 'R') f = false;
      }
      if (s[i] == 'B') {
        if (0 <= i - kb && s[i - kb] == 'B') f = false;
        if (i + kb < (int)s.size()&& s[i + kb] == 'B') f = false;
      }
    }
    if (f) res = max(res, (int)s.size());
  }
  cout << res << endl;
}
0