結果
| 問題 |
No.38 赤青白ブロック
|
| コンテスト | |
| ユーザー |
ty70
|
| 提出日時 | 2015-06-13 08:37:33 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 325 ms / 5,000 ms |
| コード長 | 1,761 bytes |
| コンパイル時間 | 1,131 ms |
| コンパイル使用メモリ | 89,872 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 12:49:58 |
| 合計ジャッジ時間 | 10,282 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cstdlib> // require abs exit atof atoi
#include <cstdio> // require scanf printf
#include <functional>
#include <numeric> // require accumulate
#include <cmath> // require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip> // require setw
#include <sstream> // require stringstream
#include <cstring> // require memset
#include <cctype> // require tolower, toupper
#include <fstream> // require freopen
#include <ctime> // require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
bool is_ok (string s, char c, int K ){
int n = s.length();
rep (i, n ){
if (s[i] == c ){
if ((i - K >= 0 && s[i-K] == c )
|| (i + K < n && s[i+K] == c ) ) return false;
} // end if
} // end rep
return true;
}
int table[32]; // R, B の位置
int main()
{
memset (table, -1, sizeof (table ) );
ios_base::sync_with_stdio(0);
int Kr, Kb; cin >> Kr >> Kb;
string S; cin >> S;
int j = 0;
rep (i, S.length() ) if (S[i] != 'W' ) table[i] = j, j++;
int res = 0;
rep (i, 1<<20 ){
string T; T = "";
rep (j, S.length() ) {
if (S[j] == 'W' ) T += S[j];
else
if (i & (1<<table[j] ) ) T += S[j];
} // end rep
bool okR = is_ok (T, 'R', Kr );
bool okB = is_ok (T, 'B', Kb );
if (okR && okB ){
int curr = __builtin_popcount(i );
if (res < curr + 10 ){
res = curr + 10;
// cerr << T << endl;
} // end if
} // end if
} // end rep
cout << res << endl;
return 0;
}
ty70