結果
問題 | No.2723 Fortune-telling by Flowers |
ユーザー | Carpenters-Cat |
提出日時 | 2024-04-12 21:52:35 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 174 ms / 2,000 ms |
コード長 | 443 bytes |
コンパイル時間 | 2,139 ms |
コンパイル使用メモリ | 201,220 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-02 23:13:54 |
合計ジャッジ時間 | 3,201 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; void solve() { int N; cin >> N; string S; cin >> S; int cnt[] = {0, 0}; string s = "-" + S + "-"; for (int i = 0; i <= N; i ++) { if (s[i] == '-' && s[i + 1] != '-') { cnt[s[i + 1] == 'P'] ++; } if (s[i + 1] == '-' && s[i] != '-') { cnt[s[i] == 'P'] ++; } } cout << (cnt[0] >= cnt[1] ? "K" : "P") << endl; } int main () { int tt; cin >> tt; while (tt--) { solve(); } }