結果

問題 No.2692 How Many Times Reached?
ユーザー ikomaikoma
提出日時 2024-03-22 21:37:09
言語 Rust
(1.77.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 4,000 bytes
コンパイル時間 1,583 ms
コンパイル使用メモリ 196,008 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-22 21:37:17
合計ジャッジ時間 2,975 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 1 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 1 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 1 ms
6,676 KB
testcase_16 AC 1 ms
6,676 KB
testcase_17 AC 1 ms
6,676 KB
testcase_18 AC 1 ms
6,676 KB
testcase_19 AC 1 ms
6,676 KB
testcase_20 AC 1 ms
6,676 KB
testcase_21 AC 1 ms
6,676 KB
testcase_22 AC 1 ms
6,676 KB
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 1 ms
6,676 KB
testcase_25 AC 1 ms
6,676 KB
testcase_26 AC 1 ms
6,676 KB
testcase_27 AC 1 ms
6,676 KB
testcase_28 AC 1 ms
6,676 KB
testcase_29 AC 1 ms
6,676 KB
testcase_30 AC 1 ms
6,676 KB
testcase_31 AC 1 ms
6,676 KB
testcase_32 AC 1 ms
6,676 KB
testcase_33 AC 1 ms
6,676 KB
testcase_34 AC 2 ms
6,676 KB
testcase_35 AC 2 ms
6,676 KB
testcase_36 AC 1 ms
6,676 KB
testcase_37 AC 1 ms
6,676 KB
testcase_38 AC 1 ms
6,676 KB
testcase_39 AC 2 ms
6,676 KB
testcase_40 AC 1 ms
6,676 KB
testcase_41 AC 1 ms
6,676 KB
testcase_42 AC 2 ms
6,676 KB
testcase_43 AC 1 ms
6,676 KB
testcase_44 AC 1 ms
6,676 KB
testcase_45 AC 1 ms
6,676 KB
testcase_46 AC 1 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_imports, dead_code, unused_macros, unused_variables, non_snake_case, unused_parens)]
use std::cmp::*;
use std::mem::swap;
use std::collections::*;

const MOD:u64 = 1_000_000_007;
const INF:i64 = 0x7fff_ffff_ffff_ffff;

macro_rules! min {($a:expr $(,)*) => {{$a}};($a:expr, $b:expr $(,)*) => {{std::cmp::min($a, $b)}};($a:expr, $($rest:expr),+ $(,)*) => {{std::cmp::min($a, min!($($rest),+))}};}
macro_rules! max {($a:expr $(,)*) => {{$a}};($a:expr, $b:expr $(,)*) => {{std::cmp::max($a, $b)}};($a:expr, $($rest:expr),+ $(,)*) => {{std::cmp::max($a, max!($($rest),+))}};}
macro_rules! chmin {($base:expr, $($cmps:expr),+ $(,)*) => {{let cmp_min = min!($($cmps),+);if $base > cmp_min {$base = cmp_min;true} else {false}}};}
macro_rules! chmax {($base:expr, $($cmps:expr),+ $(,)*) => {{let cmp_max = max!($($cmps),+);if $base < cmp_max {$base = cmp_max;true} else {false}}};}
macro_rules! mulvec {($x:expr; $s:expr) => {vec![$x; $s]};($x:expr; $s0:expr; $( $s:expr );+) => {mulvec![vec![$x; $s0]; $( $s );+ ]};}
macro_rules! outputln {($var:expr)=>{println!("{}",$var)};($var:expr,$($vars:expr),+)=>{print!("{} ",$var);outputln!($($vars),+);};}
macro_rules! debug {($($a:expr),* $(,)*) => {eprintln!(concat!($("| ",stringify!($a), "={:?} "),*, "|"),$(&$a),*);};}


fn solve() {
    input! {
        n: usize,
		S:[String;n],
    }
	let S = S.into_iter().map(|s| s.chars().collect::<Vec<char>>()).collect::<Vec<Vec<char>>>();
    let mut ans = 0;
	for i in 0..n {
		let mut a=0;
		let mut b=0;
		for &s in S[i].iter() {
			if s=='A' {
				a+=1;
			}else if s=='B' {
				b+=1;
			}
		}
		if a==n-1 && b==0 {
			ans +=1;
		}
		let mut a=0;
		let mut b=0;
		for j in 0..n {
			let s = S[j][i];
			if s=='A' {
				a+=1;
			}else if s=='B' {
				b+=1;
			}
		}
		if a==n-1 && b==0 {
			ans +=1;
		}
	}
	let mut a=0;
	let mut b=0;
	for i in 0..n {
		let s = S[i][i];
		if s=='A' {
			a+=1;
		}else if s=='B' {
			b+=1;
		}
	}
	if a==n-1 && b==0 {
		ans +=1;
	}
	let mut a=0;
	let mut b=0;
	for i in 0..n {
		let s = S[n-1-i][i];
		if s=='A' {
			a+=1;
		}else if s=='B' {
			b+=1;
		}
	}
	if a==n-1 && b==0 {
		ans +=1;
	}
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(128 * 1024 * 1024)
        .spawn(|| solve()).unwrap()
        .join().unwrap();
}


mod _input {
    // https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
    #[macro_export]
    macro_rules! input {
        (source = $s:expr, $($r:tt)*) => {
            let mut iter = $s.split_whitespace();
            let mut next = || { iter.next().unwrap() };
            input_inner!{next, $($r)*}
        };
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }
    #[macro_export]
    macro_rules! input_inner {
        ($next:expr) => {};
        ($next:expr, ) => {};

        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }
    #[macro_export]
    macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };

        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };

        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };

        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };

        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }
}


0