結果

問題 No.2021 Not A but B
ユーザー phsplsphspls
提出日時 2022-09-03 23:48:02
言語 Rust
(1.77.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 13,931 ms
コンパイル使用メモリ 379,372 KB
実行使用メモリ 9,576 KB
最終ジャッジ日時 2024-04-28 20:05:38
合計ジャッジ時間 15,324 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 0 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 0 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 24 ms
9,436 KB
testcase_09 AC 23 ms
9,444 KB
testcase_10 AC 23 ms
9,440 KB
testcase_11 AC 23 ms
9,404 KB
testcase_12 AC 23 ms
9,404 KB
testcase_13 AC 22 ms
9,412 KB
testcase_14 AC 23 ms
9,432 KB
testcase_15 AC 21 ms
9,416 KB
testcase_16 AC 24 ms
9,420 KB
testcase_17 AC 23 ms
9,404 KB
testcase_18 AC 22 ms
9,448 KB
testcase_19 AC 22 ms
9,576 KB
testcase_20 AC 23 ms
9,508 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 8 ms
6,940 KB
testcase_27 AC 24 ms
9,408 KB
testcase_28 AC 22 ms
9,476 KB
testcase_29 AC 24 ms
9,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::HashSet;


fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let s = s.trim().chars().collect::<Vec<char>>();

    let mut patterns = HashSet::new();
    for i in 0..n-1 {
        if s[i] == 'A' && s[i+1] == 'A' {
            patterns.insert((i+1, i+2));
        } else if s[i] == 'A' {
            patterns.insert((i+1, 0));
        } else if s[i+1] == 'A' {
            patterns.insert((i+2, 0));
        } else {
            patterns.insert((0, 0));
        }
    }
    println!("{}", patterns.len());
}
0