結果

問題 No.2723 Fortune-telling by Flowers
ユーザー ensembleaverageensembleaverage
提出日時 2024-04-12 22:06:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 2,444 bytes
コンパイル時間 1,643 ms
コンパイル使用メモリ 164,368 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-12 22:06:51
合計ジャッジ時間 3,170 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"


/*#include "boost/multiprecision/cpp_int.hpp"
namespace mp = boost::multiprecision;
using i128=mp::cpp_int;*/


using namespace std;
using namespace chrono;
typedef long long ll;
typedef int64_t i64;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pllll;
typedef vector<pii> vpii;
typedef vector<vector<pii>> vvpii;
typedef vector<vector<vector<pii>>> vvvpii;
typedef vector<pllll> vpllll;
typedef vector<vector<pllll>> vvpllll;
typedef vector<vector<vector<pllll>>> vvvpllll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define drep(i,a,n) for(int i=a;i>n;i--)
#define yes(ans) {if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;}
#define Yes(ans) {if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;}
#define YES(ans) {if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;}
#define printv(vec) {rep(first_,0,vec.size()) cout << vec[first_] << ' '; cout << endl;}
#define printvv(vec) {rep(first_,0,vec.size()) {rep(second_,0,vec[first_].size()) cout << vec[first_][second_] << ' '; cout << endl;}; cout<<endl;}
#define iINF 2000000007
#define lINF 10000000000007
#define llINF 9000000000000000007
#define all(x) x.begin(),x.end()
#define so(x) sort(all(x))
#define re(x) reverse(all(x))
#define mod 998244353
const double PI = acos(-1);

void solve(){
    int n; cin>>n;
    string st; cin>>st;
    int k=0,p=0;
    int now=0;
    rep(i,0,n){
        if(now==0){
            if(st[i]=='K'){
                now=1;
                k++;
            }
            else if(st[i]=='P'){
                now=-1;
                p++;
            }
        }
        else if(now==1){
            if(st[i]=='-'){
                now=0;
            }
            else if(st[i]=='P'){
                now=-1;
                p++;
            }
        }
        else{
            if(st[i]=='-'){
                now=0;
            }
            else if(st[i]=='K'){
                now=1;
                k++;
            }
        }
    }
    if(k>=p){
        cout<<'K'<<endl;
    }
    else cout<<'P'<<endl;
    return;
}

int main(){
    int t; cin>>t;
    rep(i,0,t){
        solve();
    }
}
0