結果

問題 No.38 赤青白ブロック
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-07-15 13:15:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,190 ms / 5,000 ms
コード長 977 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 86,788 KB
実行使用メモリ 81,476 KB
最終ジャッジ日時 2023-10-15 04:12:47
合計ジャッジ時間 53,898 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,819 ms
80,392 KB
testcase_01 AC 2,190 ms
80,908 KB
testcase_02 AC 1,870 ms
80,932 KB
testcase_03 AC 2,137 ms
80,924 KB
testcase_04 AC 1,824 ms
81,036 KB
testcase_05 AC 1,549 ms
81,184 KB
testcase_06 AC 1,942 ms
81,476 KB
testcase_07 AC 1,951 ms
80,720 KB
testcase_08 AC 1,534 ms
80,272 KB
testcase_09 AC 1,839 ms
81,008 KB
testcase_10 AC 1,501 ms
79,848 KB
testcase_11 AC 1,523 ms
79,996 KB
testcase_12 AC 1,721 ms
79,888 KB
testcase_13 AC 1,578 ms
80,496 KB
testcase_14 AC 1,812 ms
80,724 KB
testcase_15 AC 1,772 ms
80,284 KB
testcase_16 AC 2,013 ms
81,080 KB
testcase_17 AC 1,796 ms
81,100 KB
testcase_18 AC 1,691 ms
80,048 KB
testcase_19 AC 1,766 ms
80,060 KB
testcase_20 AC 1,896 ms
81,296 KB
testcase_21 AC 1,996 ms
81,468 KB
testcase_22 AC 1,884 ms
80,920 KB
testcase_23 AC 1,654 ms
80,552 KB
testcase_24 AC 2,036 ms
81,216 KB
testcase_25 AC 1,718 ms
81,128 KB
testcase_26 AC 1,723 ms
79,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
# input = sys.stdin.readline

Kr,Kb = map(int,input().split())
S = list(input())
A = []
for s in S:
    if s=='R':
        A.append(2)
    elif s=='B':
        A.append(1)
    else:
        A.append(0)

R = []
B = []
for i,s in enumerate(S):
    if s=='R':
        R.append(i)
    if s=='B':
        B.append(i)
S = A[:]

def is_ok(X):
    
    T = []
    for i,s in enumerate(S):
        if i in X:
            continue
        T.append(s)
    
    if any((T[i]==1)&(T[i]==T[i+Kb]) for i in range(len(T)-Kb)):
        return -1
        
    if any((T[i]==2)&(T[i]==T[i+Kr]) for i in range(len(T)-Kr)):
        return -1
        
    return len(T)
   
Z = R+B
ans = -1

for i in range(1<<20):
    
    
    X = []
    
    for j in range(20):
        
        if (i>>j)&1:
            X.append(Z[j])
        
    X = set(X)
    ans = max(ans,is_ok(X))
print(ans)
    
0