Submission #50291674


Source Code Expand

use std::{
    cmp::Reverse,
    collections::{BTreeMap, HashMap},
};

use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        s: [String; n],
    };

    let mut map = HashMap::new();
    for s_i in s {
        *map.entry(s_i).or_insert(0_usize) += 1;
    }

    let mut map2 = BTreeMap::new();
    for (s, c) in map {
        map2.entry(Reverse(c)).or_insert_with(Vec::new).push(s);
    }

    let mut sum = 0_usize;
    for (_, ss) in map2.into_iter() {
        if sum + ss.len() < k {
            sum += ss.len();
            continue;
        }
        if ss.len() == 1 {
            println!("{}", ss[0]);
        } else {
            println!("AMBIGUOUS");
        }
        return;
    }
}

Submission Info

Submission Time
Task F - 構文解析
User bouzuya
Language Rust (rustc 1.70.0)
Score 7
Code Size 733 Byte
Status AC
Exec Time 21 ms
Memory 14620 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 7 / 7
Status
AC × 3
AC × 43
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All all_different_00.txt, all_different_01.txt, all_different_02.txt, handmade_00.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
all_different_00.txt AC 21 ms 14620 KiB
all_different_01.txt AC 17 ms 12260 KiB
all_different_02.txt AC 9 ms 7860 KiB
handmade_00.txt AC 1 ms 2176 KiB
random_00.txt AC 15 ms 9832 KiB
random_01.txt AC 10 ms 8264 KiB
random_02.txt AC 10 ms 8000 KiB
random_03.txt AC 9 ms 7884 KiB
random_04.txt AC 9 ms 7772 KiB
random_05.txt AC 9 ms 7912 KiB
random_06.txt AC 7 ms 5928 KiB
random_07.txt AC 10 ms 8320 KiB
random_08.txt AC 9 ms 7868 KiB
random_09.txt AC 6 ms 5568 KiB
random_10.txt AC 9 ms 7492 KiB
random_11.txt AC 4 ms 4016 KiB
random_12.txt AC 6 ms 5000 KiB
random_13.txt AC 10 ms 8220 KiB
random_14.txt AC 3 ms 3420 KiB
random_15.txt AC 9 ms 7724 KiB
random_16.txt AC 7 ms 6248 KiB
random_17.txt AC 4 ms 4052 KiB
random_18.txt AC 8 ms 6552 KiB
random_19.txt AC 2 ms 2804 KiB
random_20.txt AC 1 ms 2316 KiB
random_21.txt AC 7 ms 6268 KiB
random_22.txt AC 7 ms 6424 KiB
random_23.txt AC 4 ms 4672 KiB
random_24.txt AC 7 ms 6020 KiB
random_25.txt AC 4 ms 4156 KiB
random_26.txt AC 4 ms 4072 KiB
random_27.txt AC 8 ms 6380 KiB
random_28.txt AC 7 ms 6520 KiB
random_29.txt AC 4 ms 4160 KiB
random_30.txt AC 11 ms 8152 KiB
random_31.txt AC 4 ms 4352 KiB
random_32.txt AC 5 ms 4692 KiB
random_33.txt AC 8 ms 7040 KiB
random_34.txt AC 3 ms 3280 KiB
random_35.txt AC 8 ms 7112 KiB
sample_01.txt AC 0 ms 2180 KiB
sample_02.txt AC 0 ms 2024 KiB
sample_03.txt AC 0 ms 2028 KiB