結果

問題 No.2723 Fortune-telling by Flowers
ユーザー 沙耶花沙耶花
提出日時 2024-04-12 21:37:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 865 bytes
コンパイル時間 4,841 ms
コンパイル使用メモリ 257,484 KB
実行使用メモリ 21,600 KB
最終ジャッジ日時 2024-04-12 21:37:32
合計ジャッジ時間 6,341 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 7 ms
6,812 KB
testcase_02 AC 41 ms
6,940 KB
testcase_03 AC 166 ms
6,944 KB
testcase_04 AC 191 ms
6,940 KB
testcase_05 AC 28 ms
20,944 KB
testcase_06 AC 13 ms
6,940 KB
testcase_07 AC 31 ms
21,424 KB
testcase_08 AC 31 ms
21,600 KB
testcase_09 AC 42 ms
6,940 KB
testcase_10 AC 23 ms
6,940 KB
testcase_11 AC 25 ms
6,940 KB
testcase_12 AC 29 ms
7,104 KB
testcase_13 AC 31 ms
17,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001


int main(){

/*
	for(int i=1;i<=20;i++){
		cout<<i<<' '<<check(i,0)<<endl;
	}*/
	int _t;
	cin>>_t;
	rep(_,_t){
		int n;
		cin>>n;
		string s;
		cin>>s;
		
		vector<string> t;
		rep(i,n){
			if(s[i]=='-')t.push_back("");
			else{
				if(t.size()==0 || t.back()=="")t.push_back(string(1,s[i]));
				else t.back() += s[i];
			}
		}
		int X = 0,Y = 0;
		rep(i,t.size()){
			if(t[i].size()==0 || t[i][0]!=t[i].back())continue;
			if(t[i][0]=='P')X++;
			else Y++;
		}
		while(true){
			X--;
			if(X<0){
				cout<<"K"<<endl;
				break;
			}
			Y--;
			if(Y<0){
				cout<<"P"<<endl;
				break;
			}
		}
	}
	
	return 0;
}
0