結果

問題 No.2723 Fortune-telling by Flowers
コンテスト
ユーザー 回転
提出日時 2025-10-23 18:27:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 550 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 82,644 KB
実行使用メモリ 139,108 KB
最終ジャッジ日時 2025-10-23 18:27:37
合計ジャッジ時間 4,703 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

def rle(S):
    ret = []
    now = None
    count = 0
    for i in S:
        if(now == i):
            count += 1
        else:
            if(count > 0):ret.append((now,count))
            now = i
            count = 1
    ret.append((now,count))
    return ret

for _ in range(T):
    N = int(input())
    S = input()

    rl = [(a,b) for a,b in rle(S) if a != "-"]
    P = len([a for a,b in rl if a == "P"])
    K = len([a for a,b in rl if a == "K"])
    print("K" if K >= P else "P")
0