結果

問題 No.291 黒い文字列
ユーザー gew1fw
提出日時 2025-06-12 15:37:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 671 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 58,524 KB
最終ジャッジ日時 2025-06-12 15:38:21
合計ジャッジ時間 2,286 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input().strip()
n = len(S)
used = [False] * n
count = 0

target = ['K', 'U', 'R', 'O', 'I']

while True:
    positions = [-1] * 5
    current_pos = -1
    for i in range(5):
        found = False
        for j in range(current_pos + 1, n):
            if not used[j]:
                c = S[j]
                if c == '?':
                    c = target[i]
                if c == target[i]:
                    positions[i] = j
                    used[j] = True
                    current_pos = j
                    found = True
                    break
        if not found:
            break
    else:
        count += 1
        continue
    break

print(count)
0