結果
問題 | No.38 赤青白ブロック |
ユーザー | どらら |
提出日時 | 2015-06-17 01:45:35 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 1,210 ms / 5,000 ms |
コード長 | 1,118 bytes |
コンパイル時間 | 719 ms |
コンパイル使用メモリ | 84,208 KB |
実行使用メモリ | 34,224 KB |
最終ジャッジ日時 | 2023-08-25 01:07:51 |
合計ジャッジ時間 | 4,382 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 14 ms
4,376 KB |
testcase_01 | AC | 634 ms
21,032 KB |
testcase_02 | AC | 45 ms
5,084 KB |
testcase_03 | AC | 9 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 114 ms
7,756 KB |
testcase_07 | AC | 62 ms
5,960 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 172 ms
9,760 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 1 ms
4,376 KB |
testcase_12 | AC | 1 ms
4,380 KB |
testcase_13 | AC | 2 ms
4,380 KB |
testcase_14 | AC | 1 ms
4,376 KB |
testcase_15 | AC | 23 ms
4,688 KB |
testcase_16 | AC | 111 ms
7,108 KB |
testcase_17 | AC | 9 ms
4,380 KB |
testcase_18 | AC | 25 ms
4,380 KB |
testcase_19 | AC | 42 ms
5,004 KB |
testcase_20 | AC | 15 ms
4,376 KB |
testcase_21 | AC | 7 ms
4,376 KB |
testcase_22 | AC | 1,210 ms
34,224 KB |
testcase_23 | AC | 2 ms
4,376 KB |
testcase_24 | AC | 77 ms
6,540 KB |
testcase_25 | AC | 7 ms
4,380 KB |
testcase_26 | AC | 14 ms
4,380 KB |
ソースコード
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cctype> #include <cmath> #include <iostream> #include <queue> #include <list> #include <map> #include <numeric> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; int ret; map<string,int> memo; void solve(int Kr, int Kb, string S){ if(ret > S.length()) return; if(memo.count(S) > 0) return; memo[S] = 1; bool flg = false; rep(i,S.length()){ if(S[i] == 'R' && i+Kr<S.length() && S[i+Kr]=='R') flg = true; if(S[i] == 'B' && i+Kb<S.length() && S[i+Kb]=='B') flg = true; } if(flg){ rep(i,S.length()){ solve(Kr, Kb, S.substr(0,i) + S.substr(i+1)); } }else{ ret = max(ret, (int)(S.length())); } } int main(){ int Kr, Kb; string S; cin >> Kr >> Kb; cin >> S; ret = 3; solve(Kr, Kb, S); cout << ret << endl; return 0; }