結果
問題 | No.38 赤青白ブロック |
ユーザー | mamekin |
提出日時 | 2015-01-14 21:55:22 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 267 ms / 5,000 ms |
コード長 | 1,166 bytes |
コンパイル時間 | 837 ms |
コンパイル使用メモリ | 91,908 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 12:41:38 |
合計ジャッジ時間 | 8,784 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
#include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> using namespace std; int main() { int kr, kb; string s; cin >> kr >> kb >> s; int ret = 0; for(int i=0; i<(1<<20); ++i){ bitset<32> bs(i); string t; int k = 0; for(int j=0; j<30; ++j){ if(s[j] == 'W'){ t += 'W'; } else{ if(bs[k]) t += s[j]; ++ k; } } bool ok = true; for(unsigned j=0; j<t.size(); ++j){ if(t[j] == 'R' && j + kr < t.size() && t[j+kr] == 'R') ok = false; if(t[j] == 'B' && j + kb < t.size() && t[j+kb] == 'B') ok = false; } if(ok) ret = max<int>(ret, t.size()); } cout << ret << endl; return 0; }