結果
| 問題 |
No.38 赤青白ブロック
|
| コンテスト | |
| ユーザー |
togari_takamoto
|
| 提出日時 | 2016-02-26 15:04:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 235 ms / 5,000 ms |
| コード長 | 1,014 bytes |
| コンパイル時間 | 1,404 ms |
| コンパイル使用メモリ | 163,704 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 12:58:10 |
| 合計ジャッジ時間 | 8,057 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>; using vb = vector<bool>; using vd = vector<double>; using vl = vector<ll>;
using vvi = vector<vi>; using vvb = vector<vb>; using vvd = vector<vd>; using vvl = vector<vl>;
#define REP(i,n) for(ll i=0; i<(n); ++i)
ll kr, kb;
string s;
vl pos;
ll recur(ll depth, vb & enable){
if (depth == pos.size()) {
string ns; REP(i, s.size()) if (enable[i]) ns.push_back(s[i]);
REP(i, ns.size()) {
if (ns[i] == 'W') continue;
ll d = ns[i] == 'R' ? kr : kb;
if (i - d >= 0 && ns[i - d] == ns[i]) return -1;
if (i + d < ns.size() && ns[i + d] == ns[i]) return -1;
}
return ns.size();
}
ll ans = recur(depth + 1, enable);
enable[pos[depth]] = false;
ans = max(ans, recur(depth + 1, enable));
enable[pos[depth]] = true;
return ans;
}
int main() {
cin >> kr >> kb >> s;
REP(i, s.size()) if(s[i]!='W') pos.push_back(i);
vb enable(s.size(), true);
cout << recur(0, enable) << endl;
return 0;
}
togari_takamoto