結果

問題 No.2723 Fortune-telling by Flowers
ユーザー powellpowell
提出日時 2024-04-12 22:54:26
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,403 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 169,448 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-12 22:54:28
合計ジャッジ時間 1,825 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]

use proconio::{
    input,
    marker::{Bytes, Chars, Usize1},
};

macro_rules! debug {
    ( $($val:expr),* $(,)* ) => {{
        #[cfg(debug_assertions)]
        eprintln!( concat!($(stringify!($val), " = {:?}, "),*), $($val),* );
    }};
}

macro_rules! debug2D {
    ( $array:expr ) => {{
        #![cfg(debug_assertions)]
        eprintln!("{}: ", stringify!($array));
        for row in &$array {
            eprintln!("{:?}", row);
        }
    }};
}

// constant
const MOD1: usize = 1_000_000_007;
const MOD9: usize = 998_244_353;
const INF: usize = 1001001001001001001;

fn main() {
    input! {
        T: usize,
    }

    for _ in 0..T {
        solve();
    }
}

fn solve() {
    input! {
        N: usize,
        S: String,
    }

    // K, Pそれぞれのnim和
    let (nimK, nimP) = S
        .split('-')
        .map(|s| {
            let mut cnt = (0_usize, 0_usize);
            for c in s.chars() {
                if c == 'K' {
                    cnt.0 += 1;
                } else {
                    cnt.1 += 1;
                }
            }
            cnt
        })
        .fold((0, 0), |(k, p), (a, b)| (k ^ a, p ^ b));

    debug!(nimK, nimP);

    if nimK ^ nimP == 0 {
        println!("P");
    } else {
        println!("K");
    }
}
0