結果

問題 No.2723 Fortune-telling by Flowers
ユーザー PNJPNJ
提出日時 2024-04-12 21:38:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 449 ms / 2,000 ms
コード長 665 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 78,744 KB
最終ジャッジ日時 2024-04-12 21:38:37
合計ジャッジ時間 3,268 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,624 KB
testcase_01 AC 155 ms
77,196 KB
testcase_02 AC 230 ms
78,356 KB
testcase_03 AC 367 ms
78,036 KB
testcase_04 AC 449 ms
78,184 KB
testcase_05 AC 47 ms
61,688 KB
testcase_06 AC 55 ms
64,908 KB
testcase_07 AC 60 ms
66,560 KB
testcase_08 AC 60 ms
67,300 KB
testcase_09 AC 229 ms
78,744 KB
testcase_10 AC 120 ms
76,348 KB
testcase_11 AC 78 ms
72,492 KB
testcase_12 AC 74 ms
72,620 KB
testcase_13 AC 75 ms
73,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
  N = int(input())
  S = input()
  P,K,T = 0,0,0
  f,s,g = 0,0,0
  for i in range(N):
    if f == 0:
      if S[i] != '-':
        if S[i] == 'P':
          s = 1
          g = 1
        else:
          s = 2
          g = 2
        f = 1
    else:
      if S[i] == '-':
        if s == g:
          if s == 1:
            P += 1
          else:
            K += 1
        else:
          T += 1
        f = 0
      elif S[i] == 'P':
        g = 1
      else:
        g = 2
  if f:
    if s != g:
      T += 1
    else:
      if s == 1:
        P += 1
      else:
        K += 1
  if K >= P:
    print('K')
  else:
    print('P')
0