結果
問題 | No.2723 Fortune-telling by Flowers |
ユーザー |
|
提出日時 | 2024-04-12 23:18:40 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 156 ms / 2,000 ms |
コード長 | 765 bytes |
コンパイル時間 | 2,787 ms |
コンパイル使用メモリ | 243,488 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-02 23:47:31 |
合計ジャッジ時間 | 3,884 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h>using namespace std;void solve(){int n;cin >> n;string S;cin >> S;int num = 0;int now = 0;while (now < n){if (S[now] == '-'){now++;continue;}char sta = S[now];while (now < n && S[now] != '-'){now++;}char en = S[now-1];if (sta != en) continue;if (sta == 'P'){num++;} else{num--;}}if (num > 0){cout << "P" << endl;} else{cout << "K" << endl;}}int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int t;cin >> t;for (int i = 0; i < t; i++){solve();}return 0;}