只能过 1 和 4 测试点,能不能提供一些测试数据?
查看原帖
只能过 1 和 4 测试点,能不能提供一些测试数据?
526704
ovo_tim楼主2024/2/24 22:53

我用 Rust 写的

use std::io;
use std::collections::HashMap;

fn main() {
    let (mut a, mut b, mut c, mut d) = (String::new(), String::new(), String::new(), String::new());
    io::stdin()
            .read_line(&mut a)
            .expect("Failed to read line");
    io::stdin()
            .read_line(&mut b)
            .expect("Failed to read line");
    io::stdin()
            .read_line(&mut c)
            .expect("Failed to read line");
    io::stdin()
            .read_line(&mut d)
            .expect("Failed to read line");

    let mut map: HashMap<char, u32> = HashMap::new();
    let mut mx = 0;
    for c in a.chars() {
        let n = map.entry(c).or_insert(0);
        *n += 1;
        mx = mx.max(*n);
    }
    for c in b.chars() {
        let n = map.entry(c).or_insert(0);
        *n += 1;
        mx = mx.max(*n);
    }
    for c in c.chars() {
        let n = map.entry(c).or_insert(0);
        *n += 1;
        mx = mx.max(*n);
    }
    for c in d.chars() {
        let n = map.entry(c).or_insert(0);
        *n += 1;
        mx = mx.max(*n);
    }

    // let mut outputing:HashMap<u32, bool> = HashMap::new();
    for i in (1..=mx).rev() {
        for j in 'A'..='Z'{
            // if map.get(&j) == None{
            //     continue;
            // }
            if map.get(&j) >= Some(&i){
                print!("*");
            }else{
                print!(" ");
            }
            print!(" ");
        }
        println!();
    }
    for j in 'A'..='Z'{
        // if map.get(&j) == None{
        //     continue;
        // }
        print!("{}", j);
        print!(" ");
    }
}

等级不够,下不了测试数据,谢谢

2024/2/24 22:53
加载中...