結果

問題 No.2723 Fortune-telling by Flowers
ユーザー 👑 ygussanyygussany
提出日時 2024-03-30 10:26:19
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 595 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 29,568 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-30 10:26:21
合計ジャッジ時間 1,730 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 19 ms
6,676 KB
testcase_04 WA -
testcase_05 AC 4 ms
6,676 KB
testcase_06 AC 4 ms
6,676 KB
testcase_07 AC 6 ms
6,676 KB
testcase_08 AC 6 ms
6,676 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 6 ms
6,676 KB
testcase_12 WA -
testcase_13 AC 6 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int solve(int N, char S[])
{
	int i, j, num[3] = {};
	for (i = 0; i < N; i = j + 1) {
		if (S[i] == '-') {
			j = i;
			continue;
		}
		for (j = i; j < N && S[j] != '-'; j++);
		j--;
		if (S[i] != S[j]) num[2]++;
		else if (S[i] == 'K') num[0]++;
		else num[1]++;
	}
	num[0] += (num[2] + 1) / 2;
	num[1] += num[2] / 2;
	if (num[0] >= num[1]) return 1;
	else return 0;
}

int main()
{
	int T, N;
	char S[500001];
	scanf("%d", &T);
	while (T--) {
		scanf("%d", &N);
		scanf("%s", S);
		if (solve(N, S) != 0) printf("K\n");
		else printf("P\n");
	}
	fflush(stdout);
	return 0;
}
0