結果
| 問題 |
No.38 赤青白ブロック
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2022-12-20 00:40:46 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 243 ms / 5,000 ms |
| コード長 | 1,118 bytes |
| コンパイル時間 | 1,184 ms |
| コンパイル使用メモリ | 142,188 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-18 01:38:17 |
| 合計ジャッジ時間 | 8,097 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
using namespace std;
int r, b;
bool check(string &T){
for (int i=0; i<30; i++){
if (T[i] == 'R'){
if ((i-r >= 0 && T[i-r] == 'R') || (i+r < T.size() && T[i+r] == 'R')) return 0;
}
else if (T[i] == 'B'){
if ((i-b >= 0 && T[i-b] == 'B') || (i+b < T.size() && T[i+b] == 'B')) return 0;
}
}
return 1;
}
int main(){
int cnt, mx=0;
string S, T;
cin >> r >> b >> S;
for (int i=(1<<20)-1; i>=0; i--){
T = "";
cnt = 0;
for (int j=0; j<20; j++){
while (j+cnt < 30 && S[j+cnt] == 'W'){
T += 'W';
cnt++;
}
if (i & (1<<j)) T += S[j+cnt];
}
while (20+cnt < 30 && S[20+cnt] == 'W'){
T += 'W';
cnt++;
}
if (check(T)) mx = max(mx, (int)T.size());
}
cout << mx << endl;
return 0;
}
srjywrdnprkt