結果

問題 No.2723 Fortune-telling by Flowers
ユーザー detteiuudetteiuu
提出日時 2024-04-12 22:32:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,110 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 81,136 KB
最終ジャッジ日時 2024-04-12 22:32:17
合計ジャッジ時間 3,769 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,128 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 379 ms
77,740 KB
testcase_04 WA -
testcase_05 AC 52 ms
62,596 KB
testcase_06 AC 57 ms
64,588 KB
testcase_07 AC 65 ms
67,392 KB
testcase_08 AC 65 ms
67,748 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 93 ms
74,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

for _ in range(T):
    N = int(input())
    S = input()
    K = 0
    P = 0
    d = 0
    left = 0
    right = 0
    for i in range(len(S)):
        if i == 0 and S[i] != "-" or i >= 1 and S[i-1] == "-" and S[i] != "-":
            if S[i] == "K":
                left = 0
            else:
                left = 1
        if i >= 1 and S[i-1] != "-" and S[i] == "-":
            if S[i-1] == "K":
                right = 0
            else:
                right = 1
            if left == right:
                if left == 0:
                    K += 1
                else:
                    P += 1
            else:
                if d == 0:
                    K += 1
                else:
                    P += 1
                d ^= 1
    if S[-1] != "-":
        if S[-1] == "K":
            right = 0
        else:
            right = 1
    if left == right:
        if left == 0:
            K += 1
        else:
            P += 1
    else:
        if d == 0:
            K += 1
        else:
            P += 1
    if K >= P:
        print("K")
    else:
        print("P")
0