結果
| 問題 |
No.2723 Fortune-telling by Flowers
|
| コンテスト | |
| ユーザー |
eve__fuyuki
|
| 提出日時 | 2024-04-12 21:40:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,251 bytes |
| コンパイル時間 | 2,053 ms |
| コンパイル使用メモリ | 195,632 KB |
| 最終ジャッジ日時 | 2025-02-21 00:11:32 |
|
ジャッジサーバーID (参考情報) |
judge4 / 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");
}
}
eve__fuyuki