結果
問題 | No.2723 Fortune-telling by Flowers |
ユーザー |
|
提出日時 | 2024-05-04 16:44:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 138 ms / 2,000 ms |
コード長 | 597 bytes |
コンパイル時間 | 3,775 ms |
コンパイル使用メモリ | 251,728 KB |
最終ジャッジ日時 | 2025-02-21 10:55:51 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 |
ソースコード
#include<bits/stdc++.h>using namespace std;#include<atcoder/all>using namespace atcoder;using ll = long long;int N;string S;void solve(){S.insert(S.begin(),'-');S.insert(S.end(),'-');N += 2;int cntK = 0,cntP = 0;for(int i = 0;i<N-1;i++){if(S[i]=='-'&&S[i+1]!='-'){if(S[i+1]=='K')cntK++;else cntP++;}if(S[i]!='-'&&S[i+1]=='-'){if(S[i]=='K')cntK++;else cntP++;}}if(cntK>=cntP) cout<<"K"<<endl;else cout<<"P"<<endl;}signed main(){cin.tie(nullptr);ios::sync_with_stdio(false);int T;cin >> T;while(T--){cin >> N >> S;solve();}}