結果

問題 No.2723 Fortune-telling by Flowers
ユーザー detteiuudetteiuu
提出日時 2024-04-12 22:28:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,108 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 80,996 KB
最終ジャッジ日時 2024-04-12 22:28:19
合計ジャッジ時間 3,686 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,820 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 353 ms
77,816 KB
testcase_04 WA -
testcase_05 AC 51 ms
62,772 KB
testcase_06 WA -
testcase_07 AC 62 ms
66,120 KB
testcase_08 AC 61 ms
67,088 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

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] == "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