結果

問題 No.2723 Fortune-telling by Flowers
ユーザー titiatitia
提出日時 2024-04-12 23:00:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 414 ms / 2,000 ms
コード長 523 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 24,076 KB
最終ジャッジ日時 2024-04-12 23:01:03
合計ジャッジ時間 4,034 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 60 ms
10,752 KB
testcase_02 AC 219 ms
10,624 KB
testcase_03 AC 276 ms
10,880 KB
testcase_04 AC 414 ms
10,624 KB
testcase_05 AC 139 ms
11,772 KB
testcase_06 AC 157 ms
15,144 KB
testcase_07 AC 253 ms
24,072 KB
testcase_08 AC 246 ms
24,076 KB
testcase_09 AC 219 ms
10,624 KB
testcase_10 AC 204 ms
10,752 KB
testcase_11 AC 207 ms
11,008 KB
testcase_12 AC 221 ms
13,500 KB
testcase_13 AC 241 ms
18,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

T=int(input())
for tests in range(T):
    N=int(input())
    S=input().strip()

    LIST=[]
    now=[]
    for s in S:
        if s=="-":
            if now!=[]:
                LIST.append(now)
            now=[]
        else:
            now+=[s]

    if now!=[]:
        LIST.append(now)

    P=0
    K=0

    for l in LIST:
        if l[0]==l[-1]=="P":
            P+=1
        elif l[0]==l[-1]=="K":
            K+=1

    if K>=P:
        print("K")
    else:
        print("P")
0