結果

問題 No.2723 Fortune-telling by Flowers
ユーザー hirakuuuuhirakuuuu
提出日時 2024-04-12 21:51:30
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 1,222 bytes
コンパイル時間 3,866 ms
コンパイル使用メモリ 275,220 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-12 21:51:35
合計ジャッジ時間 5,465 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 7 ms
6,944 KB
testcase_02 AC 33 ms
6,940 KB
testcase_03 AC 186 ms
6,940 KB
testcase_04 AC 173 ms
6,940 KB
testcase_05 AC 12 ms
6,940 KB
testcase_06 AC 15 ms
6,944 KB
testcase_07 AC 16 ms
6,944 KB
testcase_08 AC 16 ms
6,944 KB
testcase_09 AC 33 ms
6,944 KB
testcase_10 AC 18 ms
6,940 KB
testcase_11 AC 16 ms
6,944 KB
testcase_12 AC 16 ms
6,944 KB
testcase_13 AC 17 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for(int i = a; i < n; i++)
#define rrep(i, a, n) for(int i = a; i >= n; i--)
#define inr(l, x, r) (l <= x && x < r)
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
// constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
constexpr int IINF = 1001001001;
constexpr ll INF = 9e18;

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

ll power(ll a, ll b, ll m=MOD){
    ll res = 1;
    while(b > 0){
        if(b%2 == 1) res = res*a%m;
        a = a*a%m;
        b /= 2;
    }
    return res;
}



int main(){
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        string s; cin >> s;
        int p = 0, k = 0;
        rep(i, 0, n){
            if(s[i] == '-') continue;
            if(s[i] == 'P'){
                p++;
                while(i < n && s[i] == 'P') i++;
            }
            if(s[i] == 'K'){
                k++;
                while(i < n && s[i] == 'K') i++;
            }
            i--;
        }
        if(k >= p) cout << "K" << endl;
        else cout << "P" << endl;

    }
    return 0;
}
0