結果
問題 | No.38 赤青白ブロック |
ユーザー | dearorange31 |
提出日時 | 2017-09-09 16:21:03 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 540 ms / 5,000 ms |
コード長 | 1,135 bytes |
コンパイル時間 | 768 ms |
コンパイル使用メモリ | 69,836 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-08-25 01:26:24 |
合計ジャッジ時間 | 15,949 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 538 ms
4,376 KB |
testcase_01 | AC | 494 ms
4,380 KB |
testcase_02 | AC | 494 ms
4,380 KB |
testcase_03 | AC | 507 ms
4,376 KB |
testcase_04 | AC | 493 ms
4,380 KB |
testcase_05 | AC | 540 ms
4,376 KB |
testcase_06 | AC | 488 ms
4,380 KB |
testcase_07 | AC | 493 ms
4,376 KB |
testcase_08 | AC | 530 ms
4,376 KB |
testcase_09 | AC | 509 ms
4,376 KB |
testcase_10 | AC | 525 ms
4,380 KB |
testcase_11 | AC | 528 ms
4,376 KB |
testcase_12 | AC | 514 ms
4,380 KB |
testcase_13 | AC | 538 ms
4,384 KB |
testcase_14 | AC | 509 ms
4,376 KB |
testcase_15 | AC | 539 ms
4,380 KB |
testcase_16 | AC | 473 ms
4,376 KB |
testcase_17 | AC | 496 ms
4,380 KB |
testcase_18 | AC | 520 ms
4,376 KB |
testcase_19 | AC | 512 ms
4,380 KB |
testcase_20 | AC | 507 ms
4,380 KB |
testcase_21 | AC | 499 ms
4,380 KB |
testcase_22 | AC | 525 ms
4,380 KB |
testcase_23 | AC | 527 ms
4,380 KB |
testcase_24 | AC | 504 ms
4,380 KB |
testcase_25 | AC | 529 ms
4,380 KB |
testcase_26 | AC | 515 ms
4,376 KB |
ソースコード
#include<iostream> #include<string> #include<map> using namespace std; int main(){ int kr,kb; cin >> kr >> kb; string s; cin >> s; map<int,int> mp; int ind = 0; for(int i = 0;i < s.size();i++){ if(s[i] != 'W'){ mp[i] = ind; ind++; } } int ans = 0; for(int i = ((1 << 20) - 1);i >= 0;i--){ int tn = 0; string tests = ""; for(int j = 0;j < s.size();j++){ if(s[j] == 'W'){ tests += s.substr(j,1); }else{ if((i >> mp[j]) % 2 == 1){ tests += s.substr(j,1); tn++; } } } bool ok = true; for(int j = 0;j < tests.size();j++){ if(tests[j] == 'B'){ if(j >= kb){ if(tests[j - kb] == 'B' || tests[j + kb] == 'B'){ ok = false; break; } }else{ if(tests[j + kb] == 'B'){ ok = false; break; } } }else if(tests[j] == 'R'){ if(j >= kr){ if(tests[j - kr] == 'R' || tests[j + kr] == 'R'){ ok = false; break; } }else{ if(tests[j + kr] == 'R'){ ok = false; break; } } } } if(ok){ ans = max(ans,tn); } } cout << (ans + 10) << endl; return 0; }