結果

問題 No.672 最長AB列
ユーザー tomato5515tomato5515
提出日時 2018-06-15 13:48:43
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,017 bytes
コンパイル時間 571 ms
コンパイル使用メモリ 140,556 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-13 04:35:25
合計ジャッジ時間 4,296 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

fn main(){
    let s = getline();
    let s = s.trim();
    let length:isize = s.len() as isize;
    let c = s.chars().collect::<Vec<char>>();
    let mut ans:i32 = -1;
    // println!("{:?}", s.char_at());
    for i in 0..length {
        ans = check_char(&c, length, length-i);
        if ans != 0 {
            break;
        }
    }
    println!("{}", ans);    
}
fn getline() -> String{
	let mut __ret=String::new();
	std::io::stdin().read_line(&mut __ret).ok();
	return __ret;
}
fn check_char(c: &Vec<char>, length:isize, check_len: isize) -> i32{
    let mut count_a:i32 = 0;
    let mut count_b:i32 = 0;
    let mut i:isize = 0;
    //count A
    //count B
    while i + check_len <= length {
        for j in i..(check_len+i) {
            if c[j as usize] == 'A' {count_a+=1;} 
            if c[j as usize] == 'B' {count_b+=1;} 
        }
        if count_a == count_b {break;}
        i+=1;
    }
    // println!("{:?}", c);
    if count_a == count_b && count_a !=0 {return count_a+count_b}
    return 0;
}
0