結果

問題 No.38 赤青白ブロック
ユーザー mkawa2mkawa2
提出日時 2020-01-08 18:32:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 880 ms / 5,000 ms
コード長 793 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-05-02 13:01:12
合計ジャッジ時間 12,985 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 397 ms
10,624 KB
testcase_01 AC 666 ms
10,752 KB
testcase_02 AC 442 ms
10,752 KB
testcase_03 AC 391 ms
10,752 KB
testcase_04 AC 392 ms
10,752 KB
testcase_05 AC 388 ms
10,624 KB
testcase_06 AC 398 ms
10,752 KB
testcase_07 AC 413 ms
10,752 KB
testcase_08 AC 412 ms
10,752 KB
testcase_09 AC 409 ms
10,752 KB
testcase_10 AC 415 ms
10,624 KB
testcase_11 AC 402 ms
10,624 KB
testcase_12 AC 388 ms
10,624 KB
testcase_13 AC 396 ms
10,624 KB
testcase_14 AC 391 ms
10,624 KB
testcase_15 AC 400 ms
10,752 KB
testcase_16 AC 412 ms
10,624 KB
testcase_17 AC 392 ms
10,624 KB
testcase_18 AC 423 ms
10,752 KB
testcase_19 AC 393 ms
10,752 KB
testcase_20 AC 397 ms
10,624 KB
testcase_21 AC 403 ms
10,624 KB
testcase_22 AC 880 ms
10,624 KB
testcase_23 AC 402 ms
10,752 KB
testcase_24 AC 410 ms
10,624 KB
testcase_25 AC 386 ms
10,624 KB
testcase_26 AC 413 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
def MI(): return map(int, sys.stdin.readline().split())

def ok(bit):
    a = []
    for i, c in enumerate(s):
        if c == "R":
            if bit & 1:
                if len(a) >= kr and a[-kr] == 1: return False
                a.append(1)
            bit >>= 1
        elif c == "B":
            if bit & 1:
                if len(a) >= kb and a[-kb] == 2: return False
                a.append(2)
            bit >>= 1
        else:
            a.append(0)
    return True

def main():
    popcnt = lambda x: bin(x).count("1")
    ans = 0
    # 1がたっている所を残す
    for bit in range(1 << 20):
        p = popcnt(bit)
        if p <= ans: continue
        if ok(bit): ans = p
    print(ans+10)

kr, kb = MI()
s = input()
main()
0