Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // use std::fmt::Write;
- use std::collections::btree_map::BTreeMap;
- type INT = u64;
- pub fn main() {
- let buf_size: usize = 1000000;
- let mut input = String::with_capacity(buf_size);
- // let mut output = String::with_capacity(buf_size);
- std::io::stdin().read_line(&mut input).unwrap();
- input.pop();
- let n = input.len();
- let mut odd_count: i64 = 0;
- let mut middle = '#';
- let mut alphabet: BTreeMap<char, INT> = BTreeMap::from
- ([('A', 0), ('B', 0), ('C', 0), ('D', 0), ('E', 0), ('F', 0),
- ('G', 0), ('H', 0), ('I', 0), ('J', 0), ('K', 0), ('L', 0),
- ('M', 0), ('N', 0), ('O', 0), ('P', 0), ('Q', 0), ('R', 0),
- ('S', 0), ('T', 0), ('U', 0), ('V', 0), ('W', 0), ('X', 0),
- ('Y', 0), ('Z', 0)]);
- for c in input.chars() {
- *alphabet.entry(c).or_insert(0) += 1;
- }
- for (_, v) in &alphabet {
- if v % 2 != 0 { odd_count += 1 }
- }
- if odd_count > 1 {
- println!("NO SOLUTION");
- return;
- }
- if n == 1 {
- for (c, v) in alphabet {
- if v == 1 {
- println!("{}", c);
- }
- }
- return;
- }
- if n % 2 == 1 {
- for (c, v) in alphabet {
- if v % 2 == 1 {
- middle = c;
- }
- }
- }
- for (_, mut v) in alphabet.clone() {
- v = v / 2;
- }
- println!("{}", input.len());
- }
Advertisement