結果

問題 No.2723 Fortune-telling by Flowers
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-04-12 21:59:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 734 bytes
コンパイル時間 2,205 ms
コンパイル使用メモリ 195,548 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-12 21:59:10
合計ジャッジ時間 3,340 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 18 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 5 ms
6,944 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 7 ms
6,940 KB
testcase_08 AC 8 ms
6,944 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 7 ms
6,940 KB
testcase_13 AC 8 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    fast_io();
    int t;
    cin >> t;
    for (; t--;) {
        int n;
        string s;
        cin >> n >> s;
        s = "-" + s + "-";
        int p = 0, k = 0;
        for (int i = 1; i <= n; i++) {
            if (s[i] == '-') {
                continue;
            }
            if (s[i - 1] == '-' || s[i + 1] == '-') {
                if (s[i] == 'P') {
                    p++;
                } else {
                    k++;
                }
            }
        }
        if (p > k) {
            cout << "P\n";
        } else {
            cout << "K\n";
        }
    }
}
0