結果

問題 No.2723 Fortune-telling by Flowers
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2024-04-12 21:52:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 2,117 ms
コンパイル使用メモリ 196,964 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-12 21:52:39
合計ジャッジ時間 3,602 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 6 ms
6,944 KB
testcase_02 AC 33 ms
6,940 KB
testcase_03 AC 166 ms
6,944 KB
testcase_04 AC 179 ms
6,940 KB
testcase_05 AC 13 ms
6,944 KB
testcase_06 AC 12 ms
6,940 KB
testcase_07 AC 15 ms
6,940 KB
testcase_08 AC 15 ms
6,940 KB
testcase_09 AC 32 ms
6,940 KB
testcase_10 AC 31 ms
6,940 KB
testcase_11 AC 14 ms
6,940 KB
testcase_12 AC 17 ms
6,940 KB
testcase_13 AC 15 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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();
	}
}
0