結果

問題 No.2268 NGワード回避
ユーザー haihamabossuhaihamabossu
提出日時 2023-04-14 22:13:27
言語 Rust
(1.77.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,829 bytes
コンパイル時間 7,091 ms
コンパイル使用メモリ 152,192 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 19:41:23
合計ジャッジ時間 6,320 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

use std::collections::BTreeSet;

fn solve(scanner: &mut Scanner) {
    let n: usize = scanner.next();
    let mut set = BTreeSet::<usize>::new();
    for _ in 0..n {
        let s: Vec<char> = scanner.next::<String>().chars().collect();
        let mut a = 0;
        for i in 0..(n.min(15)) {
            a <<= 1;
            if s[i] == 'b' {
                a += 1;
            }
        }
        set.insert(a);
    }
    for a in 0..=1010 {
        if set.contains(&a) {
            continue;
        }
        let mut ans: Vec<char> = vec![];
        let mut a = a;
        for _ in 0..(n.min(15)) {
            if (a & 1) == 1 {
                ans.push('b');
            } else {
                ans.push('a');
            }
            a >>= 1;
        }
        ans.reverse();
        for _ in (n.min(15))..n {
            ans.push('a');
        }
        let ans: String = ans
            .iter()
            .map(|a| a.to_string())
            .collect::<Vec<_>>()
            .join("");
        println!("{}", ans);
        return;
    }
}

fn main() {
    let mut scanner = Scanner::new();
    let t: usize = 1;
    for _ in 0..t {
        solve(&mut scanner);
    }
}

struct Scanner {
    buf: Vec<String>,
}

impl Scanner {
    fn new() -> Self {
        Self { buf: vec![] }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(x) = self.buf.pop() {
                return x.parse().ok().expect("");
            }
            let mut source = String::new();
            std::io::stdin().read_line(&mut source).expect("");
            self.buf = Self::split(source);
        }
    }

    fn split(source: String) -> Vec<String> {
        source
            .split_whitespace()
            .rev()
            .map(String::from)
            .collect::<Vec<_>>()
    }
}
0