Submission #19220066


Source Code Expand

Copy
use std::collections::BTreeMap;

use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars,
        t: Chars,
    };

    let mut map_s = BTreeMap::new();
    for s_i in s.iter() {
        *map_s.entry(s_i).or_insert(0) += 1;
    }
    let mut map_t = BTreeMap::new();
    for t_i in t.iter() {
        *map_t.entry(t_i).or_insert(0) += 1;
    }

    if map_s != map_t {
        println!("NO");
        return;
    }

    let p = s
        .iter()
        .zip(t.iter())
        .filter(|(s_i, t_i)| s_i != t_i)
        .map(|(&s_i, &t_i)| (s_i, t_i))
        .collect::<Vec<(char, char)>>();

    if p.len() > 6 {
        println!("NO");
        return;
    }

    match p.len() {
        0 | 3 | 4 | 5 => println!(
            "{}",
            if map_s.iter().filter(|(_, &v)| v >= 2).count() > 0 {
                "YES"
            } else {
                "NO"
            }
        ),
        2 | 6 => println!("YES"),
        1 => unreachable!(),
        _ => unreachable!(),
    }
}

Submission Info

Submission Time
Task C - 仲良し文字列
User bouzuya
Language Rust (1.42.0)
Score 100
Code Size 1026 Byte
Status AC
Exec Time 6 ms
Memory 2188 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 86
Set Name Test Cases
All manual_01.txt, manual_02.txt, manual_03.txt, manual_04.txt, manual_05.txt, manual_06.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, sample_06.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt, test_55.txt, test_56.txt, test_57.txt, test_58.txt, test_59.txt, test_60.txt, test_62.txt, test_63.txt, test_64.txt, test_65.txt, test_66.txt, test_67.txt, test_68.txt, test_69.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, sample_06.txt
Case Name Status Exec Time Memory
manual_01.txt AC 6 ms 2052 KB
manual_02.txt AC 2 ms 2116 KB
manual_03.txt AC 1 ms 2080 KB
manual_04.txt AC 2 ms 2072 KB
manual_05.txt AC 1 ms 2048 KB
manual_06.txt AC 2 ms 2008 KB
sample_01.txt AC 2 ms 2096 KB
sample_02.txt AC 2 ms 2100 KB
sample_03.txt AC 2 ms 2048 KB
sample_04.txt AC 3 ms 2092 KB
sample_05.txt AC 2 ms 2064 KB
sample_06.txt AC 2 ms 2160 KB
test_01.txt AC 2 ms 2156 KB
test_02.txt AC 2 ms 1956 KB
test_03.txt AC 1 ms 2168 KB
test_04.txt AC 2 ms 2164 KB
test_05.txt AC 2 ms 2128 KB
test_06.txt AC 2 ms 2000 KB
test_07.txt AC 2 ms 2088 KB
test_08.txt AC 2 ms 1996 KB
test_09.txt AC 2 ms 2132 KB
test_10.txt AC 2 ms 2000 KB
test_11.txt AC 2 ms 2104 KB
test_12.txt AC 2 ms 2124 KB
test_13.txt AC 2 ms 2188 KB
test_14.txt AC 2 ms 1956 KB
test_15.txt AC 2 ms 1988 KB
test_16.txt AC 2 ms 2052 KB
test_17.txt AC 1 ms 2092 KB
test_18.txt AC 2 ms 1992 KB
test_19.txt AC 2 ms 2092 KB
test_20.txt AC 2 ms 2020 KB
test_21.txt AC 2 ms 2024 KB
test_22.txt AC 2 ms 2144 KB
test_23.txt AC 2 ms 2068 KB
test_24.txt AC 2 ms 2032 KB
test_25.txt AC 2 ms 2076 KB
test_26.txt AC 2 ms 2056 KB
test_27.txt AC 2 ms 2044 KB
test_28.txt AC 2 ms 2064 KB
test_29.txt AC 2 ms 1984 KB
test_30.txt AC 2 ms 1976 KB
test_31.txt AC 4 ms 2084 KB
test_32.txt AC 3 ms 1980 KB
test_33.txt AC 2 ms 2132 KB
test_34.txt AC 2 ms 2072 KB
test_35.txt AC 2 ms 2020 KB
test_36.txt AC 2 ms 1916 KB
test_37.txt AC 2 ms 2060 KB
test_38.txt AC 2 ms 2108 KB
test_39.txt AC 2 ms 1992 KB
test_40.txt AC 1 ms 2120 KB
test_41.txt AC 6 ms 2084 KB
test_42.txt AC 2 ms 2104 KB
test_43.txt AC 2 ms 2072 KB
test_44.txt AC 2 ms 2020 KB
test_45.txt AC 2 ms 2164 KB
test_46.txt AC 2 ms 2104 KB
test_47.txt AC 1 ms 2060 KB
test_48.txt AC 2 ms 2052 KB
test_49.txt AC 2 ms 2088 KB
test_50.txt AC 2 ms 2084 KB
test_51.txt AC 2 ms 2112 KB
test_52.txt AC 3 ms 2084 KB
test_53.txt AC 2 ms 2096 KB
test_54.txt AC 2 ms 2068 KB
test_55.txt AC 2 ms 1976 KB
test_56.txt AC 3 ms 2176 KB
test_57.txt AC 2 ms 2104 KB
test_58.txt AC 2 ms 2116 KB
test_59.txt AC 2 ms 2072 KB
test_60.txt AC 2 ms 2020 KB
test_62.txt AC 2 ms 2008 KB
test_63.txt AC 2 ms 2092 KB
test_64.txt AC 2 ms 1952 KB
test_65.txt AC 2 ms 2140 KB
test_66.txt AC 2 ms 2080 KB
test_67.txt AC 3 ms 2108 KB
test_68.txt AC 2 ms 2112 KB
test_69.txt AC 2 ms 1992 KB