結果
問題 | No.2723 Fortune-telling by Flowers |
ユーザー | hato336 |
提出日時 | 2024-04-12 21:54:58 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 195 ms / 2,000 ms |
コード長 | 507 bytes |
コンパイル時間 | 371 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 147,660 KB |
最終ジャッジ日時 | 2024-10-02 23:15:32 |
合計ジャッジ時間 | 2,769 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 |
ソースコード
import sys input = sys.stdin.readline for i in range(int(input())): n = int(input()) s = list(input().rstrip()) def rle(s): res = [] for j in s: if not res or res[-1][0] != j: res.append([j,1]) else: res[-1][1] += 1 return res p,k = 0,0 x = rle(s) for j,z in x: if j == 'P': p += 1 if j == 'K': k += 1 if p > k: print('P') else: print('K')