結果

問題 No.2723 Fortune-telling by Flowers
ユーザー 🦠みどりむし🦠みどりむし
提出日時 2024-04-12 22:38:13
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 220 ms / 2,000 ms
コード長 3,242 bytes
コンパイル時間 4,046 ms
コンパイル使用メモリ 280,440 KB
実行使用メモリ 8,764 KB
最終ジャッジ日時 2024-04-12 22:38:19
合計ジャッジ時間 5,577 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 7 ms
6,812 KB
testcase_02 AC 38 ms
6,944 KB
testcase_03 AC 160 ms
6,940 KB
testcase_04 AC 220 ms
6,940 KB
testcase_05 AC 13 ms
6,940 KB
testcase_06 AC 13 ms
6,940 KB
testcase_07 AC 23 ms
8,764 KB
testcase_08 AC 42 ms
8,640 KB
testcase_09 AC 38 ms
6,940 KB
testcase_10 AC 20 ms
6,940 KB
testcase_11 AC 19 ms
6,944 KB
testcase_12 AC 20 ms
6,948 KB
testcase_13 AC 23 ms
7,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
 * @uni_kakurenbo
 * https://github.com/uni-kakurenbo/competitive-programming-workspace
 *
 * CC0 1.0  http://creativecommons.org/publicdomain/zero/1.0/deed.ja
 */
/* #language C++ 20 GCC */

#include <bits/stdc++.h>

/* [begin]: snippet/aliases.hpp */
#include <cstdint>
#include <utility>
#include <vector>
#include <ranges>
/* [begin]: internal/dev_env.hpp */
#ifdef LOCAL_JUDGE
inline constexpr bool DEV_ENV = true; inline constexpr bool NO_EXCEPT = false;
#else
inline constexpr bool DEV_ENV = false; inline constexpr bool NO_EXCEPT = true;
#endif
#if __cplusplus >= 202100L
#define CPP20 true
#define CPP23 true
#elif __cplusplus >= 202002L
#define CPP20 true
#define CPP23 false
#else
#define CPP20 false
#define CPP23 false
#endif
/* [end]: internal/dev_env.hpp*/
/* [begin]: snippet/internal/types.hpp */
namespace lib { using i16 = std::int16_t; using u16 = std::uint16_t; using i32 = std::int32_t; using u32 = std::uint32_t; using i64 = std::int64_t; using u64 = std::uint64_t;
#ifdef __GNUC__
using i128 = __int128_t; using u128 = __uint128_t;
#endif
using uint = unsigned; using ll = long long; using ull = unsigned long long; using ld = long double; }
/* [end]: snippet/internal/types.hpp*/
#define until(...) while(!(__VA_ARGS__))
#define CONTINUE(...) { __VA_ARGS__; continue; }
#define BREAK(...) { __VA_ARGS__; break; }
#define ALL(x) std::ranges::begin((x)),std::ranges::end((x))
#define RALL(x) std::ranges::rbegin((x)),std::ranges::rend((x))
#define $F first
#define $S second
namespace lib { constexpr char LN = '\n'; constexpr char SPC = ' '; constexpr std::pair<int,int> DIRS4[] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } }; constexpr std::pair<int,int> DIRS4P[] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 }, { 0, 0 } }; constexpr std::pair<int,int> DIRS8[] = { { -1, 0 }, { -1, 1 }, { 0, 1 }, { 1, 1 }, { 1, 0 }, { 1, -1 }, { 0, -1 }, { -1, -1 } }; constexpr std::pair<int,int> DIRS8P[] = { { -1, 0 }, { -1, 1 }, { 0, 1 }, { 1, 1 }, { 1, 0 }, { 1, -1 }, { 0, -1 }, { -1, -1 }, { 0, 0 } }; template<class T> using spair = std::pair<T,T>; } namespace std { using bit_reference = std::vector<bool>::reference; bit_reference operator |= (bit_reference a, const bool b) noexcept(NO_EXCEPT) { return a = a | b; } bit_reference operator &= (bit_reference a, const bool b) noexcept(NO_EXCEPT) { return a = a & b; } }
/* [end]: snippet/aliases.hpp*/

void solve();

signed main() {
    int $ = 1;
    std::cin >> $;
    for(int _ = 0; _ < $; ++_) {
        solve();
    }
    return 0;
}



void solve() {
    int n; std::cin >> n;
    std::string s; std::cin >> s;

    std::vector<std::string> seq;
    std::string cur;
    for(const auto& c : s) {
        if(c == '-') {
            if(cur != "") {
                seq.push_back(cur);
                cur.clear();
            }
            continue;
        };
        cur += c;
    }
    if(cur != "") {
        seq.push_back(cur);
    }

    int p = 0;
    int k = 0;
    int m = 0;

    for(const auto& v : seq) {
        // std::cerr << v << "\n";
        if(v.front() == 'P' and v.back() == 'P') {
            p++;
        }
        else if(v.front() == 'K' and v.back() == 'K') {
            k++;
        }
    }

    std::cout << (p > k ? "P" : "K") << "\n";
}
0