結果
問題 | No.38 赤青白ブロック |
ユーザー | ty70 |
提出日時 | 2015-06-13 08:37:33 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 324 ms / 5,000 ms |
コード長 | 1,761 bytes |
コンパイル時間 | 635 ms |
コンパイル使用メモリ | 89,344 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-08-25 01:07:38 |
合計ジャッジ時間 | 10,210 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 316 ms
4,380 KB |
testcase_01 | AC | 281 ms
4,380 KB |
testcase_02 | AC | 290 ms
4,380 KB |
testcase_03 | AC | 294 ms
4,380 KB |
testcase_04 | AC | 286 ms
4,376 KB |
testcase_05 | AC | 323 ms
4,376 KB |
testcase_06 | AC | 291 ms
4,380 KB |
testcase_07 | AC | 293 ms
4,384 KB |
testcase_08 | AC | 324 ms
4,376 KB |
testcase_09 | AC | 299 ms
4,376 KB |
testcase_10 | AC | 300 ms
4,384 KB |
testcase_11 | AC | 315 ms
4,380 KB |
testcase_12 | AC | 300 ms
4,376 KB |
testcase_13 | AC | 320 ms
4,376 KB |
testcase_14 | AC | 308 ms
4,380 KB |
testcase_15 | AC | 313 ms
4,376 KB |
testcase_16 | AC | 270 ms
4,376 KB |
testcase_17 | AC | 290 ms
4,376 KB |
testcase_18 | AC | 316 ms
4,380 KB |
testcase_19 | AC | 281 ms
4,376 KB |
testcase_20 | AC | 308 ms
4,380 KB |
testcase_21 | AC | 286 ms
4,380 KB |
testcase_22 | AC | 303 ms
4,384 KB |
testcase_23 | AC | 307 ms
4,380 KB |
testcase_24 | AC | 291 ms
4,380 KB |
testcase_25 | AC | 313 ms
4,380 KB |
testcase_26 | AC | 299 ms
4,380 KB |
ソースコード
#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; }