結果

問題 No.2723 Fortune-telling by Flowers
ユーザー rlangevinrlangevin
提出日時 2024-04-12 21:38:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 416 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 82,604 KB
実行使用メモリ 77,484 KB
最終ジャッジ日時 2024-04-12 21:38:43
合計ジャッジ時間 2,264 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,888 KB
testcase_01 AC 67 ms
74,388 KB
testcase_02 AC 126 ms
77,152 KB
testcase_03 AC 114 ms
76,900 KB
testcase_04 AC 168 ms
77,484 KB
testcase_05 AC 54 ms
76,092 KB
testcase_06 AC 64 ms
76,568 KB
testcase_07 AC 67 ms
76,240 KB
testcase_08 AC 67 ms
76,536 KB
testcase_09 AC 132 ms
77,040 KB
testcase_10 AC 76 ms
75,164 KB
testcase_11 AC 66 ms
74,960 KB
testcase_12 AC 66 ms
74,820 KB
testcase_13 AC 66 ms
76,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def solve(s):
    k, p = 0, 0
    s += "-"
    N = len(s)
    for i in range(N - 1):
        if s[i] != s[i + 1] and s[i] != "-":
            if s[i] == "K":
                k += 1
            else:
                p += 1
    return k >= p

T = int(input())
for _ in range(T):
    N = int(input())
    if solve(input().rstrip()):
        print("K")
    else:
        print("P")
0