結果
問題 |
No.38 赤青白ブロック
|
ユーザー |
|
提出日時 | 2021-02-04 23:39:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 271 ms / 5,000 ms |
コード長 | 1,014 bytes |
コンパイル時間 | 866 ms |
コンパイル使用メモリ | 93,644 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 04:40:40 |
合計ジャッジ時間 | 8,791 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <iomanip> #include <cmath> #include <stdio.h> #include <queue> #include <deque> #include <cstdio> #include <set> #include <map> #include <bitset> #include <stack> #include <cctype> using namespace std; int main() { int kr, kb; cin >> kr >> kb; string s; cin >> s; int ans = 0; for (int bit = 0; bit < (1 << 20); bit++) { int r = 0, b = 10; string s1 = ""; for (int i = 0; i < 30; i++) { if (s[i] == 'R') { if (bit & (1 << r)) { s1 += 'R'; } r++; } else if (s[i] == 'B') { if (bit & (1 << b)) { s1 += 'B'; } b++; } else if (s[i] == 'W') { s1 += 'W'; } } bool bo = true; for (int i = 0; i < s1.size(); i++) { if (s1[i] == 'R' && i - kr >= 0 && s1[i - kr] == 'R') { bo = false; } if (s1[i] == 'B' && i - kb >= 0 && s1[i - kb] == 'B') { bo = false; } } if (bo && ans < s1.size()) { ans = s1.size(); } } cout << ans << endl; }