結果

問題 No.2723 Fortune-telling by Flowers
ユーザー ゼットゼット
提出日時 2024-04-12 21:40:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 407 ms / 2,000 ms
コード長 438 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 82,152 KB
実行使用メモリ 80,424 KB
最終ジャッジ日時 2024-04-12 21:40:08
合計ジャッジ時間 3,228 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
51,940 KB
testcase_01 AC 141 ms
77,264 KB
testcase_02 AC 191 ms
78,548 KB
testcase_03 AC 369 ms
77,632 KB
testcase_04 AC 407 ms
77,436 KB
testcase_05 AC 58 ms
66,588 KB
testcase_06 AC 61 ms
68,232 KB
testcase_07 AC 75 ms
76,764 KB
testcase_08 AC 76 ms
75,264 KB
testcase_09 AC 193 ms
78,300 KB
testcase_10 AC 144 ms
77,620 KB
testcase_11 AC 98 ms
76,444 KB
testcase_12 AC 97 ms
79,180 KB
testcase_13 AC 103 ms
80,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Q=int(input())
for _ in range(Q):
  N=int(input())
  S=input()
  x=0
  y=0
  used=[False]*N
  for i in range(N):
    if used[i]==True:
      continue
    if S[i]=='-':
      continue
    r=N-1
    used[i]=True
    for j in range(i+1,N):
      if S[j]=='-':
        r=j-1
        break
      used[j]=True
    if S[i]=='P' and S[r]=='P':
      y+=1
    if S[i]=='K' and S[r]=='K':
      x+=1
  if x>=y:
    print('K')
  else:
    print('P')
0