結果
| 問題 |
No.2723 Fortune-telling by Flowers
|
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2024-04-12 22:32:13 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,110 bytes |
| コンパイル時間 | 155 ms |
| コンパイル使用メモリ | 82,244 KB |
| 実行使用メモリ | 81,260 KB |
| 最終ジャッジ日時 | 2024-10-02 23:30:44 |
| 合計ジャッジ時間 | 3,230 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 7 |
ソースコード
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-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
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