Module b

Expand description

ยงABC 408 B - Compression

refs: https://atcoder.jp/contests/abc408/tasks/abc408_b

use std::collections::HashSet;

use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }

    let mut ans: Vec<_> = HashSet::<usize>::from_iter(a).into_iter().collect();
    ans.sort();

    println!("{}", ans.len());
    println!(
        "{}",
        ans.iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}