結果
問題 | No.2723 Fortune-telling by Flowers |
ユーザー |
![]() |
提出日時 | 2024-04-12 21:40:00 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,251 bytes |
コンパイル時間 | 2,228 ms |
コンパイル使用メモリ | 202,988 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-02 23:07:36 |
合計ジャッジ時間 | 3,058 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 WA * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int t; cin >> t; for (; t--;) { int n; string s; cin >> n >> s; char mi = '.', ma = '.'; for (char c : s) { if (c == '-') { continue; } if (mi == '.') { mi = c; } ma = c; } if (mi == ma) { cout << mi << "\n"; continue; } vector<int> cnt; for (char c : s) { if (c == '-') { if (!cnt.empty() && cnt.back() > 0) { cnt.push_back(0); } continue; } else { if (cnt.empty()) { cnt.push_back(1); } else { cnt.back()++; } } } if (cnt.size() == 1) { cout << "K\n"; continue; } cnt.front()--; cnt.back()--; int grundy = 0; for (int x : cnt) { grundy ^= x; } cout << (grundy ? "P\n" : "K\n"); } }