結果
問題 | No.38 赤青白ブロック |
ユーザー | ninoinui |
提出日時 | 2020-07-29 16:54:38 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 273 ms / 5,000 ms |
コード長 | 834 bytes |
コンパイル時間 | 2,101 ms |
コンパイル使用メモリ | 200,384 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-11 13:41:06 |
合計ジャッジ時間 | 10,367 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 264 ms
4,376 KB |
testcase_01 | AC | 230 ms
4,376 KB |
testcase_02 | AC | 235 ms
4,376 KB |
testcase_03 | AC | 234 ms
4,376 KB |
testcase_04 | AC | 230 ms
4,380 KB |
testcase_05 | AC | 273 ms
4,380 KB |
testcase_06 | AC | 229 ms
4,380 KB |
testcase_07 | AC | 233 ms
4,376 KB |
testcase_08 | AC | 267 ms
4,380 KB |
testcase_09 | AC | 247 ms
4,380 KB |
testcase_10 | AC | 254 ms
4,380 KB |
testcase_11 | AC | 260 ms
4,380 KB |
testcase_12 | AC | 242 ms
4,376 KB |
testcase_13 | AC | 264 ms
4,376 KB |
testcase_14 | AC | 246 ms
4,380 KB |
testcase_15 | AC | 269 ms
4,380 KB |
testcase_16 | AC | 215 ms
4,376 KB |
testcase_17 | AC | 225 ms
4,380 KB |
testcase_18 | AC | 255 ms
4,376 KB |
testcase_19 | AC | 227 ms
4,380 KB |
testcase_20 | AC | 242 ms
4,380 KB |
testcase_21 | AC | 219 ms
4,376 KB |
testcase_22 | AC | 261 ms
4,376 KB |
testcase_23 | AC | 255 ms
4,376 KB |
testcase_24 | AC | 224 ms
4,380 KB |
testcase_25 | AC | 251 ms
4,376 KB |
testcase_26 | AC | 239 ms
4,380 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; int R, B; bool f(string s) { int n = s.size(); for (int i = 0; i < n; i++) { if (s.at(i) == 'R') { if (i - R >= 0) if (s.at(i - R) == 'R') return false; if (i + R < n) if (s.at(i + R) == 'R') return false; } if (s.at(i) == 'B') { if (i - B >= 0) if (s.at(i - B) == 'B') return false; if (i + B < n) if (s.at(i + B) == 'B') return false; } } return true; } int main() { string S; cin >> R >> B >> S; int ans = 0; for (int bit = 0; bit < 1 << 20; bit++) { string tmp; int cnt = 0; for (auto c : S) { if (c == 'W') { tmp += 'W'; continue; } if (bit >> cnt & 1) { tmp += c; } cnt++; } if (f(tmp)) ans = max(ans, (int) tmp.size()); } cout << ans << "\n"; }