結果
| 問題 | 
                            No.2723 Fortune-telling by Flowers
                             | 
                    
| コンテスト | |
| ユーザー | 
                             detteiuu
                         | 
                    
| 提出日時 | 2024-04-12 22:28:15 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,108 bytes | 
| コンパイル時間 | 206 ms | 
| コンパイル使用メモリ | 81,920 KB | 
| 実行使用メモリ | 80,720 KB | 
| 最終ジャッジ日時 | 2024-10-02 23:29:06 | 
| 合計ジャッジ時間 | 3,363 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 4 WA * 9 | 
ソースコード
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")
            
            
            
        
            
detteiuu