QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#324859#8230. Submissionsucup-team296#AC ✓109ms56988kbRust31.1kb2024-02-11 00:55:152024-10-14 10:07:24

Judging History

你现在查看的是最新测评结果

  • [2024-10-14 10:07:24]
  • 管理员手动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:109ms
  • 内存:56988kb
  • [2024-10-14 10:06:11]
  • 管理员手动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:122ms
  • 内存:55552kb
  • [2024-05-20 23:50:57]
  • hack成功,自动添加数据
  • (/hack/623)
  • [2024-05-20 23:48:44]
  • hack成功,自动添加数据
  • (/hack/622)
  • [2024-02-11 00:55:17]
  • 评测
  • 测评结果:100
  • 用时:120ms
  • 内存:53832kb
  • [2024-02-11 00:55:15]
  • 提交

answer

// 
pub mod solution {
//{"name":"a","group":"Manual","url":"","interactive":false,"timeLimit":2000,"tests":[{"input":"","output":""},{"input":"","output":""},{"input":"","output":""},{"input":"","output":""}],"testType":"single","input":{"type":"stdin","fileName":null,"pattern":null},"output":{"type":"stdout","fileName":null,"pattern":null},"languages":{"java":{"taskClass":"a"}}}

use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;

#[allow(unused)]
use crate::dbg;
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::misc::binary_search::binary_search_first_true;
use crate::algo_lib::misc::rand::Random;

#[derive(Clone, Copy, Debug)]
struct Submission {
    time: i64,
    ok: bool,
}

#[derive(Clone, Debug)]
struct Team {
    by_task: HashMap<u8, Vec<Submission>>,
    name: String,
}

#[derive(Debug)]
struct TeamScore {
    cur: Score,
    best: Score,
    worst: Score,
}

impl std::ops::Add for Score {
    type Output = Score;

    fn add(self, other: Score) -> Score {
        Score {
            tasks_solved: self.tasks_solved + other.tasks_solved,
            rev_penalty: self.rev_penalty + other.rev_penalty,
        }
    }
}

impl Team {
    fn worst_single(&self) -> Score {
        let mut res = Score {
            tasks_solved: 1,
            rev_penalty: i64::MAX,
        };
        for (_, submissions) in self.by_task.iter() {
            let mut penalty = 20 * (submissions.len() - 1) as i64;
            penalty += submissions[submissions.len() - 1].time;
            let rev_penalty = -penalty;
            if rev_penalty < res.rev_penalty {
                res.rev_penalty = rev_penalty;
            }
        }
        if res.rev_penalty == i64::MAX {
            res.tasks_solved = 0;
        }
        res
    }

    fn calc_scores(&self) -> TeamScore {
        let mut cur = Score {
            tasks_solved: 0,
            rev_penalty: 0,
        };
        let mut best = Score {
            tasks_solved: 0,
            rev_penalty: 0,
        };
        let mut worst = Score {
            tasks_solved: 0,
            rev_penalty: 0,
        };
        for (_, submissions) in &self.by_task {
            let mut task_cur = Score {
                tasks_solved: 0,
                rev_penalty: 0,
            };
            let mut task_best = Score {
                tasks_solved: 0,
                rev_penalty: 0,
            };
            let mut task_worst = Score {
                tasks_solved: 0,
                rev_penalty: 0,
            };
            let mut cur_penalty = 0;
            let mut skipped_ok = false;
            for sub in submissions {
                if task_best.tasks_solved == 0 {
                    task_best.tasks_solved = 1;
                    task_best.rev_penalty = -(sub.time);
                }
                if sub.ok {
                    if task_cur.tasks_solved == 0 {
                        task_cur.tasks_solved = 1;
                        task_cur.rev_penalty = -(sub.time + cur_penalty);
                    }
                    if skipped_ok {
                        task_worst.tasks_solved = 1;
                        task_worst.rev_penalty = -(sub.time + cur_penalty);
                        break;
                    } else {
                        skipped_ok = true;
                        cur_penalty += 20;
                    }
                } else {
                    cur_penalty += 20;
                }
            }
            best = max(best + task_cur, cur + task_best);
            worst = min(worst + task_cur, cur + task_worst);
            cur = cur + task_cur;
        }
        TeamScore { cur, best, worst }
    }
}

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Copy, Debug)]
struct Score {
    tasks_solved: usize,
    rev_penalty: i64,
}

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
struct TeamAndScore {
    score: Score,
    team_id: usize,
}

fn get_gold_medels_cnt(teams: &[TeamAndScore]) -> usize {
    let mut cnt = teams.len();
    while cnt > 0 && teams[cnt - 1].score.tasks_solved == 0 {
        cnt -= 1;
    }
    if cnt == 0 {
        return 0;
    }
    let mut cnt = min(35, (cnt + 9) / 10);
    assert!(cnt > 0);
    let need_score = teams[cnt - 1].score;
    while cnt < teams.len() && teams[cnt].score == need_score {
        cnt += 1;
    }
    cnt
}

fn solve_case(teams: &[Team]) -> Vec<bool> {
    let mut scores = vec![];
    for t in teams.iter() {
        scores.push(t.calc_scores());
    }
    let mut teams_and_scores = vec![];
    for i in 0..scores.len() {
        teams_and_scores.push(TeamAndScore {
            score: scores[i].cur,
            team_id: i,
        });
    }
    teams_and_scores.sort();
    teams_and_scores.reverse();
    let mut can_gold = vec![false; teams.len()];
    let gold_limit = get_gold_medels_cnt(&teams_and_scores);
    for i in 0..gold_limit {
        can_gold[teams_and_scores[i].team_id] = true;
    }
    let mut cnt_non_zero = 0;
    for i in 0..teams.len() {
        if scores[i].cur.tasks_solved > 0 {
            cnt_non_zero += 1;
        }
    }
    for i in 0..teams.len() {
        let team_id = teams_and_scores[i].team_id;
        let best_score = scores[team_id].best;
        if best_score.tasks_solved == 0 {
            continue;
        }
        let mut now_non_zero = cnt_non_zero;
        if scores[team_id].cur.tasks_solved == 0 {
            now_non_zero += 1;
        }
        let cnt_better = binary_search_first_true(0..teams.len(), |pos| {
            teams_and_scores[pos].score <= best_score
        });
        let limit = min(35, (now_non_zero + 9) / 10);
        if cnt_better < limit {
            can_gold[team_id] = true;
        }
    }
    for i in 0..min(40, teams.len()) {
        let mut teams_and_scores = teams_and_scores.clone();
        teams_and_scores[i].score = scores[teams_and_scores[i].team_id].worst;
        teams_and_scores.sort();
        teams_and_scores.reverse();
        let gold_limit = get_gold_medels_cnt(&teams_and_scores);
        for j in 0..gold_limit {
            can_gold[teams_and_scores[j].team_id] = true;
        }
    }
    {
        let mut best_zero = vec![];
        for i in 0..teams.len() {
            if scores[i].cur.tasks_solved == 0 {
                let cur = teams[i].worst_single();
                if cur.tasks_solved == 1 {
                    best_zero.push((cur, i));
                }
            }
        }
        best_zero.sort();
        for best_zero in best_zero[..min(2, best_zero.len())].iter() {
            let mut teams_and_scores = teams_and_scores.clone();
            for pos in 0..teams_and_scores.len() {
                if teams_and_scores[pos].team_id == best_zero.1 {
                    teams_and_scores[pos].score = best_zero.0;
                    break;
                }
            }
            teams_and_scores.sort();
            teams_and_scores.reverse();
            let gold_limit = get_gold_medels_cnt(&teams_and_scores);
            for j in 0..gold_limit {
                can_gold[teams_and_scores[j].team_id] = true;
            }
        }
    }
    can_gold
}

fn solve(input: &mut Input, out: &mut Output, _test_case: usize) {
    let tc = input.usize();
    for _ in 0..tc {
        let m = input.usize();
        let mut teams = vec![];
        let mut by_name = HashMap::new();
        for _ in 0..m {
            let tname = input.string_as_string();
            if !by_name.contains_key(&tname) {
                let new_id = teams.len();
                teams.push(Team {
                    by_task: HashMap::new(),
                    name: tname.clone(),
                });
                by_name.insert(tname.clone(), new_id);
            }
            let t_id = by_name[&tname];
            let task = input.string()[0];
            let time = input.i64();
            let ok = input.string_as_string() == "accepted";
            teams[t_id]
                .by_task
                .entry(task)
                .or_insert_with(Vec::new)
                .push(Submission { time, ok });
        }
        let can_gold = solve_case(&teams);
        let mut cnt_can_gold = 0;
        let mut golds = vec![];
        for i in 0..teams.len() {
            if can_gold[i] {
                cnt_can_gold += 1;
                golds.push(teams[i].name.clone());
            }
        }
        out.println(cnt_can_gold);
        let all_golds = golds.join(" ");
        out.println(all_golds);
        // if 2 + 2 != 5 {
        //     break;
        // }
    }
}

fn solve_slow(teams: &[Team]) -> Vec<bool> {
    let mut res = vec![false; teams.len()];
    let mut update = |teams: &[Team]| {
        let mut teams_and_scores = vec![];
        for i in 0..teams.len() {
            let score = teams[i].calc_scores().cur;
            teams_and_scores.push(TeamAndScore { score, team_id: i });
        }
        teams_and_scores.sort();
        teams_and_scores.reverse();
        let gold_limit = get_gold_medels_cnt(&teams_and_scores);

        for j in 0..gold_limit {
            if !res[teams_and_scores[j].team_id] {
                // dbg!("Found", teams_and_scores[j].team_id);
                // dbg!(gold_limit);
                // for tt in teams_and_scores.iter() {
                //     dbg!(tt);
                // }
            }
            res[teams_and_scores[j].team_id] = true;
        }
    };
    update(teams);
    for t_id in 0..teams.len() {
        for task in teams[t_id].by_task.keys() {
            for sw_id in 0..teams[t_id].by_task[task].len() {
                let mut nteams = teams.to_vec();
                nteams[t_id]
                    .by_task
                    .get_mut(task)
                    .unwrap()
                    .get_mut(sw_id)
                    .unwrap()
                    .ok ^= true;
                update(&nteams);
            }
        }
    }
    res
}

fn stress() {
    for it in 146438.. {
        dbg!(it);
        let mut rnd = Random::new(it);
        const N: usize = 106;
        let teams_num = rnd.gen(1..N);
        let mut teams = vec![
            Team {
                by_task: HashMap::new(),
                name: "A".to_string(),
            };
            teams_num
        ];
        let num_submits = rnd.gen(1..2 * N);
        for _ in 0..num_submits {
            let team_id = rnd.gen(0..teams_num);
            let task = (b'A' + (rnd.gen(0..5)) as u8);
            let time = rnd.gen(1..100);
            let ok = rnd.gen_bool();
            teams[team_id]
                .by_task
                .entry(task)
                .or_insert_with(Vec::new)
                .push(Submission { time, ok });
        }
        for team in teams.iter_mut() {
            for (_, submissions) in team.by_task.iter_mut() {
                submissions.sort_by_key(|s| s.time);
            }
        }
        let teams: Vec<_> = teams.into_iter().filter(|t| t.by_task.len() > 0).collect();
        let ans = solve_case(&teams);
        let ans_slow = solve_slow(&teams);
        if ans != ans_slow {
            for (i, tt) in teams.iter().enumerate() {
                dbg!(i, tt);
            }
            dbg!(ans);
            dbg!(ans_slow);
            for i in 0..ans.len() {
                if ans[i] != ans_slow[i] {
                    dbg!(i, ans[i], ans_slow[i]);
                }
            }
            panic!();
        }
    }
}

pub(crate) fn run(mut input: Input, mut output: Output) -> bool {
    solve(&mut input, &mut output, 1);
    output.flush();
    true
}

}
pub mod algo_lib {
pub mod io {
pub mod input {
use std::fmt::Debug;
use std::io::Read;
use std::marker::PhantomData;
use std::path::Path;
use std::str::FromStr;

pub struct Input {
    input: Box<dyn Read>,
    buf: Vec<u8>,
    at: usize,
    buf_read: usize,
}

macro_rules! read_integer_fun {
    ($t:ident) => {
        #[allow(unused)]
        pub fn $t(&mut self) -> $t {
            self.read_integer()
        }
    };
}

impl Input {
    const DEFAULT_BUF_SIZE: usize = 4096;

    ///
    /// Using with stdin:
    /// ```no_run
    /// use algo_lib::io::input::Input;
    /// let stdin = std::io::stdin();
    /// let input = Input::new(Box::new(stdin));
    /// ```
    ///
    /// For read files use ``new_file`` instead.
    ///
    ///
    pub fn new(input: Box<dyn Read>) -> Self {
        Self {
            input,
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            buf_read: 0,
        }
    }

    pub fn new_stdin() -> Self {
        let stdin = std::io::stdin();
        Self::new(Box::new(stdin))
    }

    pub fn new_file<P: AsRef<Path>>(path: P) -> Self {
        let file = std::fs::File::open(&path)
            .unwrap_or_else(|_| panic!("Can't open file: {:?}", path.as_ref().as_os_str()));
        Self::new(Box::new(file))
    }

    pub fn new_with_size(input: Box<dyn Read>, buf_size: usize) -> Self {
        Self {
            input,
            buf: vec![0; buf_size],
            at: 0,
            buf_read: 0,
        }
    }

    pub fn new_file_with_size<P: AsRef<Path>>(path: P, buf_size: usize) -> Self {
        let file = std::fs::File::open(&path)
            .unwrap_or_else(|_| panic!("Can't open file: {:?}", path.as_ref().as_os_str()));
        Self::new_with_size(Box::new(file), buf_size)
    }

    pub fn get(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            let res = self.buf[self.at];
            self.at += 1;
            Some(res)
        } else {
            None
        }
    }

    pub fn peek(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            Some(self.buf[self.at])
        } else {
            None
        }
    }

    pub fn skip_whitespace(&mut self) {
        while let Some(b) = self.peek() {
            if !char::from(b).is_whitespace() {
                return;
            }
            self.get();
        }
    }

    pub fn next_token(&mut self) -> Option<Vec<u8>> {
        self.skip_whitespace();
        let mut res = Vec::new();
        while let Some(c) = self.get() {
            if char::from(c).is_whitespace() {
                break;
            }
            res.push(c);
        }
        if res.is_empty() {
            None
        } else {
            Some(res)
        }
    }

    //noinspection RsSelfConvention
    pub fn is_exhausted(&mut self) -> bool {
        self.peek().is_none()
    }

    pub fn has_more_elements(&mut self) -> bool {
        !self.is_exhausted()
    }

    pub fn read<T: Readable>(&mut self) -> T {
        T::read(self)
    }

    pub fn vec<T: Readable>(&mut self, size: usize) -> Vec<T> {
        let mut res = Vec::with_capacity(size);
        for _ in 0usize..size {
            res.push(self.read());
        }
        res
    }

    pub fn string_vec(&mut self, size: usize) -> Vec<Vec<u8>> {
        let mut res = Vec::with_capacity(size);
        for _ in 0usize..size {
            res.push(self.string());
        }
        res
    }

    pub fn read_line(&mut self) -> String {
        let mut res = String::new();
        while let Some(c) = self.get() {
            if c == b'\n' {
                break;
            }
            if c == b'\r' {
                if self.peek() == Some(b'\n') {
                    self.get();
                }
                break;
            }
            res.push(c.into());
        }
        res
    }

    #[allow(clippy::should_implement_trait)]
    pub fn into_iter<T: Readable>(self) -> InputIterator<T> {
        InputIterator {
            input: self,
            phantom: Default::default(),
        }
    }

    fn read_integer<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let res = self.read_string();
        res.parse::<T>().unwrap()
    }

    fn read_string(&mut self) -> String {
        match self.next_token() {
            None => {
                panic!("Input exhausted");
            }
            Some(res) => unsafe { String::from_utf8_unchecked(res) },
        }
    }

    pub fn string_as_string(&mut self) -> String {
        self.read_string()
    }

    pub fn string(&mut self) -> Vec<u8> {
        self.read_string().into_bytes()
    }

    fn read_char(&mut self) -> char {
        self.skip_whitespace();
        self.get().unwrap().into()
    }

    fn read_float(&mut self) -> f64 {
        self.read_string().parse().unwrap()
    }

    pub fn f64(&mut self) -> f64 {
        self.read_float()
    }

    fn refill_buffer(&mut self) -> bool {
        if self.at == self.buf_read {
            self.at = 0;
            self.buf_read = self.input.read(&mut self.buf).unwrap();
            self.buf_read != 0
        } else {
            true
        }
    }

    read_integer_fun!(i32);
    read_integer_fun!(i64);
    read_integer_fun!(i128);
    read_integer_fun!(u32);
    read_integer_fun!(u64);
    read_integer_fun!(usize);
}

pub trait Readable {
    fn read(input: &mut Input) -> Self;
}

impl Readable for String {
    fn read(input: &mut Input) -> Self {
        input.read_string()
    }
}

impl Readable for char {
    fn read(input: &mut Input) -> Self {
        input.read_char()
    }
}

impl Readable for f64 {
    fn read(input: &mut Input) -> Self {
        input.read_string().parse().unwrap()
    }
}

impl Readable for f32 {
    fn read(input: &mut Input) -> Self {
        input.read_string().parse().unwrap()
    }
}

impl<T: Readable> Readable for Vec<T> {
    fn read(input: &mut Input) -> Self {
        let size = input.read();
        input.vec(size)
    }
}

pub struct InputIterator<T: Readable> {
    input: Input,
    phantom: PhantomData<T>,
}

impl<T: Readable> Iterator for InputIterator<T> {
    type Item = T;

    fn next(&mut self) -> Option<Self::Item> {
        self.input.skip_whitespace();
        self.input.peek().map(|_| self.input.read())
    }
}

macro_rules! read_integer {
    ($t:ident) => {
        impl Readable for $t {
            fn read(input: &mut Input) -> Self {
                input.read_integer()
            }
        }
    };
}

read_integer!(i8);
read_integer!(i16);
read_integer!(i32);
read_integer!(i64);
read_integer!(i128);
read_integer!(isize);
read_integer!(u8);
read_integer!(u16);
read_integer!(u32);
read_integer!(u64);
read_integer!(u128);
read_integer!(usize);
}
pub mod output {
use std::io::Write;

pub struct Output {
    output: Box<dyn Write>,
    buf: Vec<u8>,
    at: usize,
    auto_flush: bool,
}

impl Output {
    const DEFAULT_BUF_SIZE: usize = 4096;

    pub fn new(output: Box<dyn Write>) -> Self {
        Self {
            output,
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            auto_flush: false,
        }
    }

    pub fn new_stdout() -> Self {
        let stdout = std::io::stdout();
        Self::new(Box::new(stdout))
    }

    pub fn new_file(path: impl AsRef<std::path::Path>) -> Self {
        let file = std::fs::File::create(path).unwrap();
        Self::new(Box::new(file))
    }

    pub fn new_with_auto_flush(output: Box<dyn Write>) -> Self {
        Self {
            output,
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            auto_flush: true,
        }
    }

    pub fn flush(&mut self) {
        if self.at != 0 {
            self.output.write_all(&self.buf[..self.at]).unwrap();
            self.at = 0;
            self.output.flush().expect("Couldn't flush output");
        }
    }

    pub fn print<T: Writable>(&mut self, s: T) {
        s.write(self);
    }

    pub fn println<T: Writable>(&mut self, s: T) {
        s.write(self);
        self.put(b'\n');
    }

    pub fn put(&mut self, b: u8) {
        self.buf[self.at] = b;
        self.at += 1;
        if self.at == self.buf.len() {
            self.flush();
        }
    }

    pub fn maybe_flush(&mut self) {
        if self.auto_flush {
            self.flush();
        }
    }

    pub fn print_per_line<T: Writable>(&mut self, arg: &[T]) {
        for i in arg {
            i.write(self);
            self.put(b'\n');
        }
    }

    pub fn print_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
        let mut first = true;
        for e in iter {
            if first {
                first = false;
            } else {
                self.put(b' ');
            }
            e.write(self);
        }
    }

    pub fn print_iter_ref<'a, T: 'a + Writable, I: Iterator<Item = &'a T>>(&mut self, iter: I) {
        let mut first = true;
        for e in iter {
            if first {
                first = false;
            } else {
                self.put(b' ');
            }
            e.write(self);
        }
    }
}

impl Write for Output {
    fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
        let mut start = 0usize;
        let mut rem = buf.len();
        while rem > 0 {
            let len = (self.buf.len() - self.at).min(rem);
            self.buf[self.at..self.at + len].copy_from_slice(&buf[start..start + len]);
            self.at += len;
            if self.at == self.buf.len() {
                self.flush();
            }
            start += len;
            rem -= len;
        }
        if self.auto_flush {
            self.flush();
        }
        Ok(buf.len())
    }

    fn flush(&mut self) -> std::io::Result<()> {
        self.flush();
        Ok(())
    }
}

pub trait Writable {
    fn write(&self, output: &mut Output);
}

impl Writable for &str {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}

impl Writable for String {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}

impl Writable for char {
    fn write(&self, output: &mut Output) {
        output.put(*self as u8);
    }
}

impl<T: Writable> Writable for [T] {
    fn write(&self, output: &mut Output) {
        output.print_iter_ref(self.iter());
    }
}

impl<T: Writable> Writable for Vec<T> {
    fn write(&self, output: &mut Output) {
        self[..].write(output);
    }
}

macro_rules! write_to_string {
    ($t:ident) => {
        impl Writable for $t {
            fn write(&self, output: &mut Output) {
                self.to_string().write(output);
            }
        }
    };
}

write_to_string!(u8);
write_to_string!(u16);
write_to_string!(u32);
write_to_string!(u64);
write_to_string!(u128);
write_to_string!(usize);
write_to_string!(i8);
write_to_string!(i16);
write_to_string!(i32);
write_to_string!(i64);
write_to_string!(i128);
write_to_string!(isize);
write_to_string!(f32);
write_to_string!(f64);

impl<T: Writable, U: Writable> Writable for (T, U) {
    fn write(&self, output: &mut Output) {
        self.0.write(output);
        output.put(b' ');
        self.1.write(output);
    }
}

impl<T: Writable, U: Writable, V: Writable> Writable for (T, U, V) {
    fn write(&self, output: &mut Output) {
        self.0.write(output);
        output.put(b' ');
        self.1.write(output);
        output.put(b' ');
        self.2.write(output);
    }
}
}
}
pub mod misc {
pub mod binary_search {
use crate::algo_lib::misc::num_traits::Number;
use std::ops::Range;

pub fn binary_search_first_true<T>(range: Range<T>, mut f: impl FnMut(T) -> bool) -> T
where
    T: Number,
{
    // we can't store [range.start - 1] into [left], because it could overflow
    let mut left_plus_one = range.start;
    let mut right = range.end;
    while right > left_plus_one {
        let mid = left_plus_one + (right - left_plus_one) / T::TWO;
        if f(mid) {
            right = mid;
        } else {
            left_plus_one = mid + T::ONE;
        }
    }
    right
}

pub fn binary_search_last_true<T>(range: Range<T>, mut f: impl FnMut(T) -> bool) -> Option<T>
where
    T: Number,
{
    let first_false = binary_search_first_true(range.clone(), |x| !f(x));
    if first_false == range.start {
        None
    } else {
        Some(first_false - T::ONE)
    }
}

#[test]
fn simple_stress() {
    const N: usize = 50;
    for n in 1..N {
        for cnt_false in 0..=n {
            let mut a = vec![false; cnt_false];
            a.resize(n, true);
            let mut max_f_calls = ((n + 1) as f64).log2().ceil() as i32;
            let f_is_true = |id: usize| -> bool {
                max_f_calls -= 1;
                assert!(max_f_calls >= 0);
                a[id]
            };
            let result = binary_search_first_true(0..n, f_is_true);
            assert_eq!(result, cnt_false);
        }
    }
}
}
pub mod dbg_macro {
#[macro_export]
#[allow(unused_macros)]
macro_rules! dbg {
    ($first_val:expr, $($val:expr),+ $(,)?) => {
        eprint!("[{}:{}] {} = {:?}",
                    file!(), line!(), stringify!($first_val), &$first_val);
        ($(eprint!(", {} = {:?}", stringify!($val), &$val)),+,);
        eprintln!();
    };
    ($first_val:expr) => {
        eprintln!("[{}:{}] {} = {:?}",
                    file!(), line!(), stringify!($first_val), &$first_val)
    };
}
}
pub mod gen_vector {
pub fn gen_vec<T>(n: usize, f: impl FnMut(usize) -> T) -> Vec<T> {
    (0..n).map(f).collect()
}
}
pub mod num_traits {
use std::cmp::Ordering;
use std::fmt::Debug;
use std::ops::Add;
use std::ops::AddAssign;
use std::ops::Div;
use std::ops::DivAssign;
use std::ops::Mul;
use std::ops::MulAssign;
use std::ops::Sub;
use std::ops::SubAssign;

pub trait HasConstants<T> {
    const MAX: T;
    const MIN: T;
    const ZERO: T;
    const ONE: T;
    const TWO: T;
}

pub trait ConvSimple<T> {
    fn from_i32(val: i32) -> T;
    fn to_i32(self) -> i32;
    fn to_f64(self) -> f64;
}

pub trait Signum {
    fn signum(&self) -> i32;
}

pub trait Number:
    Copy
    + Add<Output = Self>
    + AddAssign
    + Sub<Output = Self>
    + SubAssign
    + Mul<Output = Self>
    + MulAssign
    + Div<Output = Self>
    + DivAssign
    + PartialOrd
    + PartialEq
    + HasConstants<Self>
    + Default
    + Debug
    + Sized
    + ConvSimple<Self>
{
}

impl<
        T: Copy
            + Add<Output = Self>
            + AddAssign
            + Sub<Output = Self>
            + SubAssign
            + Mul<Output = Self>
            + MulAssign
            + Div<Output = Self>
            + DivAssign
            + PartialOrd
            + PartialEq
            + HasConstants<Self>
            + Default
            + Debug
            + Sized
            + ConvSimple<Self>,
    > Number for T
{
}

macro_rules! has_constants_impl {
    ($t: ident) => {
        impl HasConstants<$t> for $t {
            // TODO: remove `std` for new rust version..
            const MAX: $t = std::$t::MAX;
            const MIN: $t = std::$t::MIN;
            const ZERO: $t = 0;
            const ONE: $t = 1;
            const TWO: $t = 2;
        }

        impl ConvSimple<$t> for $t {
            fn from_i32(val: i32) -> $t {
                val as $t
            }

            fn to_i32(self) -> i32 {
                self as i32
            }

            fn to_f64(self) -> f64 {
                self as f64
            }
        }
    };
}

has_constants_impl!(i32);
has_constants_impl!(i64);
has_constants_impl!(i128);
has_constants_impl!(u32);
has_constants_impl!(u64);
has_constants_impl!(u128);
has_constants_impl!(usize);
has_constants_impl!(u8);

impl ConvSimple<Self> for f64 {
    fn from_i32(val: i32) -> Self {
        val as f64
    }

    fn to_i32(self) -> i32 {
        self as i32
    }

    fn to_f64(self) -> f64 {
        self
    }
}

impl HasConstants<Self> for f64 {
    const MAX: Self = Self::MAX;
    const MIN: Self = -Self::MAX;
    const ZERO: Self = 0.0;
    const ONE: Self = 1.0;
    const TWO: Self = 2.0;
}

impl<T: Number + Ord> Signum for T {
    fn signum(&self) -> i32 {
        match self.cmp(&T::ZERO) {
            Ordering::Greater => 1,
            Ordering::Less => -1,
            Ordering::Equal => 0,
        }
    }
}
}
pub mod rand {
use crate::algo_lib::misc::gen_vector::gen_vec;
use crate::algo_lib::misc::num_traits::Number;
use std::ops::Range;
use std::time::SystemTime;
use std::time::UNIX_EPOCH;

#[allow(dead_code)]
pub struct Random {
    state: u64,
}

impl Random {
    pub fn gen_u64(&mut self) -> u64 {
        let mut x = self.state;
        x ^= x << 13;
        x ^= x >> 7;
        x ^= x << 17;
        self.state = x;
        x
    }

    #[allow(dead_code)]
    pub fn next_in_range(&mut self, from: usize, to: usize) -> usize {
        assert!(from < to);
        (from as u64 + self.gen_u64() % ((to - from) as u64)) as usize
    }

    pub fn gen_index<T>(&mut self, a: &[T]) -> usize {
        self.gen(0..a.len())
    }

    #[allow(dead_code)]
    #[inline(always)]
    pub fn gen_double(&mut self) -> f64 {
        (self.gen_u64() as f64) / (std::usize::MAX as f64)
    }

    #[allow(dead_code)]
    pub fn new(seed: u64) -> Self {
        let state = if seed == 0 { 787788 } else { seed };
        Self { state }
    }

    pub fn new_time_seed() -> Self {
        let time = SystemTime::now();
        let seed = (time.duration_since(UNIX_EPOCH).unwrap().as_nanos() % 1_000_000_000) as u64;
        if seed == 0 {
            Self::new(787788)
        } else {
            Self::new(seed)
        }
    }

    #[allow(dead_code)]
    pub fn gen_permutation(&mut self, n: usize) -> Vec<usize> {
        let mut result: Vec<_> = (0..n).collect();
        for i in 0..n {
            let idx = self.next_in_range(0, i + 1);
            result.swap(i, idx);
        }
        result
    }

    pub fn shuffle<T>(&mut self, a: &mut [T]) {
        for i in 1..a.len() {
            a.swap(i, self.gen(0..i + 1));
        }
    }

    pub fn gen<T>(&mut self, range: Range<T>) -> T
    where
        T: Number,
    {
        let from = T::to_i32(range.start);
        let to = T::to_i32(range.end);
        assert!(from < to);
        let len = (to - from) as usize;
        T::from_i32(self.next_in_range(0, len) as i32 + from)
    }

    pub fn gen_vec<T>(&mut self, n: usize, range: Range<T>) -> Vec<T>
    where
        T: Number,
    {
        gen_vec(n, |_| self.gen(range.clone()))
    }

    pub fn gen_nonempty_range(&mut self, n: usize) -> Range<usize> {
        let x = self.gen(0..n);
        let y = self.gen(0..n);
        if x <= y {
            x..y + 1
        } else {
            y..x + 1
        }
    }

    pub fn gen_bool(&mut self) -> bool {
        self.gen(0..2) == 0
    }
}
}
}
}
fn main() {
    let input = algo_lib::io::input::Input::new_stdin();
    let mut output = algo_lib::io::output::Output::new_stdout();
    crate::solution::run(input, output);
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 2200kb

input:

2
5
TSxingxing10 G 0 rejected
TSxingxing10 B 83 accepted
aoliaoligeiliao J 98 accepted
TS1 J 118 accepted
TS1 B 263 accepted
12
AllWayTheNorth A 0 rejected
YaoYaoLingXian Y 10 accepted
XuejunXinyoudui1 X 200 rejected
XuejunXinyoudui1 X 200 accepted
LetItRot L 215 accepted
AllWayTheNorth W 250 accept...

output:

2
TSxingxing10 TS1
4
AllWayTheNorth XuejunXinyoudui1 LetItRot ImYourFan

result:

ok 2 test cases ok. (2 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 2124kb

input:

2
2
jiangly_fan A 1 accepted
jiangly B 23 accepted
3
conqueror_of_tourist A 1 accepted
conqueror_of_tourist A 2 accepted
tourist B 23 accepted

output:

2
jiangly_fan jiangly
1
conqueror_of_tourist

result:

ok 2 test cases ok. (2 test cases)

Test #3:

score: 0
Accepted
time: 0ms
memory: 2196kb

input:

2
13
A A 1 accepted
A X 1 accepted
K K 1 rejected
B B 2 accepted
C C 2 accepted
D D 2 accepted
E E 2 accepted
F F 2 accepted
G G 2 accepted
H H 2 accepted
I I 2 accepted
J J 2 accepted
K K 2 rejected
12
A A 1 accepted
A X 1 accepted
B B 2 accepted
C C 2 accepted
D D 2 accepted
E E 2 accepted
F F 2 a...

output:

11
A K B C D E F G H I J
1
A

result:

ok 2 test cases ok. (2 test cases)

Test #4:

score: 0
Accepted
time: 0ms
memory: 2088kb

input:

2
11
A A 1 accepted
B B 1 accepted
C C 2 accepted
D D 2 accepted
E E 2 accepted
F F 2 accepted
G G 2 accepted
H H 2 accepted
I I 2 accepted
J J 2 accepted
K K 2 accepted
12
A A 1 accepted
A X 1 accepted
K K 1 rejected
B B 2 accepted
C C 2 accepted
D D 2 accepted
E E 2 accepted
F F 2 accepted
G G 2 a...

output:

2
A B
2
A K

result:

ok 2 test cases ok. (2 test cases)

Test #5:

score: 0
Accepted
time: 62ms
memory: 2316kb

input:

100000
1
M3JytWoaEXxkACy_mBAQ R 111 accepted
1
sQ O 151 accepted
1
JinbrcS58gNEE5yTSkT B 140 accepted
1
cklwBY V 243 accepted
1
v_o42YmvEKFwy Q 260 rejected
1
ftQVK8S_um22w K 265 accepted
1
_bQBeFeDpYQhvZcLf9l3 Z 147 accepted
1
KvDcEAIDN A 75 rejected
1
H3MUK6 A 101 rejected
1
gxYo_oCFn2J8aIben U 54...

output:

1
M3JytWoaEXxkACy_mBAQ
1
sQ
1
JinbrcS58gNEE5yTSkT
1
cklwBY
1
v_o42YmvEKFwy
1
ftQVK8S_um22w
1
_bQBeFeDpYQhvZcLf9l3
1
KvDcEAIDN
1
H3MUK6
1
gxYo_oCFn2J8aIben
1
_isnlUGK0ddI
1
BERcVjyCp
1
6In2do_50ylch
1
f0r3SXc6brMjT
1
7njYOapSwvogA
1
x
1
y1w3KvxylfxwprRBYw
1
aGedzS
1
iPo0GDhIF
1
4Vf5RXaTmySkFcXgHLOh
1...

result:

ok 100000 test cases ok. (100000 test cases)

Test #6:

score: 0
Accepted
time: 52ms
memory: 2264kb

input:

10000
42
Bzs0PiQMXGZ5rRZ_2D G 2 accepted
9XtB_VIfbRRL E 11 accepted
FVJL M 13 rejected
a S 19 accepted
tsd Z 20 rejected
MyCqVEg1ONjZ U 22 accepted
6SgZMn N 51 rejected
Qua1Pti3vKhyQKDUm P 54 accepted
i29 M 63 accepted
zPqu D 68 rejected
xx2yiu6x C 71 rejected
fYuK1KNkuyO5HRCq L 76 rejected
tXWpYVqj...

output:

4
tsd Qua1Pti3vKhyQKDUm fYuK1KNkuyO5HRCq xiLm0TUOF3T
2
t3 JP
2
fhYPGC8W82NwJTQL 77sgqpbTIr_Zt1
2
pVWDEz 3BQ
2
tg buCeoOotAkV8DaFD6
1
UkXQ3iaNJ
2
ALTqPt7JUSLrl vwfw
1
QTEzV6tp
3
4e1l0pO8eFjZwkDo wJlbqIU 9cy_y_RNRwex8j7224hz
2
eiuF7a_ 6mbCu5zA
1
xy6QBr8ECi
3
ldaKLZb1oS1sS _Yej1PrINtydmOudwoO PezeyUurY...

result:

ok 10000 test cases ok. (10000 test cases)

Test #7:

score: 0
Accepted
time: 53ms
memory: 2288kb

input:

10000
27
bhAGFVDBjp4_Tvo U 24 accepted
bhAGFVDBjp4_Tvo O 37 rejected
bhAGFVDBjp4_Tvo D 40 accepted
bhAGFVDBjp4_Tvo H 45 accepted
bhAGFVDBjp4_Tvo B 60 rejected
bhAGFVDBjp4_Tvo J 63 accepted
bhAGFVDBjp4_Tvo M 81 rejected
bhAGFVDBjp4_Tvo M 98 rejected
bhAGFVDBjp4_Tvo D 103 rejected
bhAGFVDBjp4_Tvo Q 11...

output:

1
bhAGFVDBjp4_Tvo
2
euenQ rl
1
seny
2
nLWe5xvBqfYkN 8zfFqdixKjh
1
VDeEtfbb
1
9PAd7wtbCZMws6u
1
Wsfc5qold4uacAjI1y
2
NX6GLK3Nz h68cyLwQ7drM__pSJub
3
yOgwg U7S8zgJhR6 sdf0IGct21OeEFJ
1
acesvM9yT
1
2hQb
2
3twK2MJI_ P5
1
eGCz
3
39GgHUPovILESCd0 tLHWIEVr5i7vlKpvlP UXRu8i
1
20gsbZ25SsYp8
1
iLUv
2
vx6L7fsu...

result:

ok 10000 test cases ok. (10000 test cases)

Test #8:

score: 0
Accepted
time: 53ms
memory: 2320kb

input:

10000
2
vVflLovvnhJEO U 3 accepted
Fg P 48 rejected
12
V9UJ5hEaWiwMq3lxwKw9 P 30 accepted
CKsw M 34 rejected
dCZBzKMxgQfgBDZO R 50 rejected
A1R2kF N 54 rejected
A1R2kF X 65 accepted
HEih51ut H 68 rejected
HEih51ut J 75 rejected
l0MCFXNXlH6T2wT I 163 accepted
A1R2kF B 180 accepted
dCZBzKMxgQfgBDZO A ...

output:

1
vVflLovvnhJEO
2
V9UJ5hEaWiwMq3lxwKw9 A1R2kF
4
fLUS3NYE 5sFcoMh xgdxQ7t 2
2
S25TIbMLU5FMV6ys4 2ra47EFC7LWzxTF2tSH
2
uwm tczurXngUW
3
gWG1aLfP1Gk DNAv Zh4tWi1QdYjTblw5
1
qN_OnmRhGksD
1
pAJC7fTKPJjaxPP
2
mElj5iV4wfu Jr9Sqekor
1
_Z13N_OO
1
rn
1
HhjFL6Rg
1
2q
5
vdFavgJoOBT4vrKWv LjvEZmSkrsT eO6B_fLKDAZ...

result:

ok 10000 test cases ok. (10000 test cases)

Test #9:

score: 0
Accepted
time: 52ms
memory: 2196kb

input:

10000
4
BUqwUvN2v7co K 45 accepted
fb4ykhGx9CBzWxLcGYjf F 96 rejected
3X39YaWp0LItH14Owx R 142 rejected
7JGP4qtBonRiKpsKW U 155 rejected
3
Z0cxqdpQ69NGV5wDoht X 92 rejected
1E0aicZDqPhh E 105 accepted
a3fvTkSrKXqQipNGs4h K 261 rejected
6
LR6PY6OjDoSaZpT W 33 accepted
Et8w1E52xfM27 Q 155 accepted
LR6...

output:

1
BUqwUvN2v7co
2
Z0cxqdpQ69NGV5wDoht 1E0aicZDqPhh
1
LR6PY6OjDoSaZpT
3
YX 7f b
4
WqSH sgpEsfgf_Fd buFAkOkQ_F o7VPp
1
coTjuCSsnonAgjYkChE
2
clGo2Z4AMe9Qp GC0Lw1Di
2
IrJ_n_Ym FCCHBTUTGJTbTjEb
1
fkBpEQxhBl21ARSTVR
1
fQzlJS9JEIS97gIIG7p4
6
pqyDmprb2RmUBafc76eR ljfPMl71hE bLED4G7CY_M CVVvEx togGKu7uZzgrRh...

result:

ok 10000 test cases ok. (10000 test cases)

Test #10:

score: 0
Accepted
time: 54ms
memory: 2192kb

input:

10000
7
dBv7DiT L 42 rejected
dBv7DiT P 123 accepted
7Bj2dZF6Gy7csrXYakI T 131 rejected
9KtuO O 190 accepted
BxACEk Q 285 rejected
BxACEk Q 291 rejected
HK0pq9qsGnlkgAQT L 296 accepted
3
NQgnW3CShrFJYkKdjagN G 53 rejected
ZwZCr O 261 accepted
ZwZCr P 270 accepted
6
mbGQ7wcZYr9leKBCsFN Z 4 rejected
7...

output:

2
dBv7DiT 9KtuO
1
ZwZCr
2
7s1bgtS 4LUVnW93OFHOl6fJOmXK
4
_g2LouxyEI_BXaOYQWn pz CZNz6k1QgLrHojbY upCvWQnHRgRSQQ
3
q ungF4dKzJt290JMWNgeH t
3
6mCVqSBpHVkrNZ SuBp7xLMGCHgk 4FjAuM44Nzaz6Tc0
1
xXqqS7r1OU
1
YEHiJvhHR8OmUWz
3
m 0WZFvefoPtNo BiasA1Md2ViU
1
MzQD
2
MJJ4n2rC7YHRflGzEL L501za_ktc
1
kcQs9Clvq3t...

result:

ok 10000 test cases ok. (10000 test cases)

Test #11:

score: 0
Accepted
time: 6ms
memory: 3884kb

input:

7
110
10 A 0 accepted
0 A 100 accepted
1 A 100 accepted
2 A 100 accepted
3 A 100 accepted
4 A 100 accepted
5 A 100 accepted
6 A 100 accepted
7 A 100 accepted
8 A 100 accepted
9 A 100 accepted
0 B 100 accepted
1 B 100 accepted
2 B 100 accepted
3 B 100 accepted
4 B 100 accepted
5 B 100 accepted
6 B 10...

output:

11
10 0 1 2 3 4 5 6 7 8 9
11
0 1 2 3 4 5 6 7 8 9 10
11
0 1 2 3 4 5 6 7 8 9 10
11
100 0 1 2 3 4 5 6 7 8 9
12
100 0 1 2 3 4 5 6 7 8 9 10
36
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
35
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23...

result:

ok 7 test cases ok. (7 test cases)

Test #12:

score: 0
Accepted
time: 62ms
memory: 2504kb

input:

1000
58
8VR4968BiWGrjt0 G 1 accepted
KfduBOJVYor3ixLgzUo Y 5 accepted
r9l9P_xyc7oagiZS0ZJ G 26 accepted
PL3OrMzXRJRVskByRHHl Y 38 accepted
7wL2M4T1PWyv9rJSdzGN N 47 rejected
Vu56KH6ZGwSm E 48 rejected
8VR4968BiWGrjt0 D 53 accepted
SI7h8yP C 57 rejected
aSVEsYSH9PJjsjSAyH N 61 accepted
D3UrdM8xI S 71...

output:

5
8VR4968BiWGrjt0 PL3OrMzXRJRVskByRHHl SI7h8yP mn0iyGyqWOakTAs1Qw umqh9D
6
9M 6OSsIJ 3A4BJULiR9S f22a5ba_ze2qsm2_2k uxPAbOmdBcWg64Q52 EYdAeGI
25
19Mbp qF0kRrasPk wd5q6DH XJ9p0AKseAnbt7vmR_ 9sFtbGG4oMjSgmtZh oLi8SUSfzmANlYBZxL io_4OkSzJAGEqNUfs6R Qo8l4lQKg D6SdnJFh6xFQlZehalkc lUs4Rd_AXJR2FP48 qeyRVr...

result:

ok 1000 test cases ok. (1000 test cases)

Test #13:

score: 0
Accepted
time: 59ms
memory: 3452kb

input:

100
974
qG R 0 accepted
k2K I 0 accepted
NelrCjQd_AHSw107 D 1 accepted
ybeH_JvdmCLMOGl9x K 1 accepted
h3 Q 2 accepted
9qOW O 2 accepted
v1IWHoW7Mkuce6qH Y 2 accepted
mlypVkK5Xl1KXw3o P 2 rejected
zs X 3 accepted
1Fpyq8oUYV_aNp I 3 rejected
e1bM8xUh E 3 rejected
myaSH0LCL4hD5BlAj F 4 rejected
IJETUS2...

output:

65
qG k2K NelrCjQd_AHSw107 ybeH_JvdmCLMOGl9x 9qOW mlypVkK5Xl1KXw3o e1bM8xUh IJETUS2jG jpgL7AOwwgwK4fC LhlGfI4XZ 1qXXQyXNhDyf97IT0n QW b1rD1OQRc v8ok8uFd3 Io5tMwXAJlbYL2Wikqqq 55IlpzN c tHhnCuExgbOb 2tougTgqY91VXB3 Hy551D5ZPfvBDS PlD7x1RoiUUo jjlJFal1mKsc9bV0rJ UL aOtxLwyhTOqQrGSi o_d5R9oBv QXFitGeaP...

result:

ok 100 test cases ok. (100 test cases)

Test #14:

score: 0
Accepted
time: 59ms
memory: 10112kb

input:

10
5371
r0JLpp2hFx T 0 accepted
w19l89 X 0 rejected
PeEB Y 0 accepted
2MwVQe3 Y 0 accepted
CarjodD8k4E K 0 accepted
vNjq0LmY D 0 accepted
Bvi16IvVACG3uREuoO X 0 accepted
yMlDlaWPTluR1dk43nl6 A 0 rejected
4LBA3qILgaib4lrQ X 1 accepted
vRSpyKVAU7e I 1 rejected
627aFcGG4zh8 Z 1 rejected
FHwI U 1 accept...

output:

85
FHwI 5gGJk cvBsYzk5yn SQHfF3xgjBtkER53p ReLcBXGOh VEUvEZytpDQks JH8 yS0d5p8qP uoWF TiH UhNeNpTgJpuTp4im WiikFMuk_mwuntjRW9 KwjId5DA66 vTtpWBju yfY26k6D RYY7Oy5Ma3N_Q 3ntTBJ2G Tsv4prgzdtzBRbKoQO 3L jYd6t8Z6OsPuQA aXGT Piy FlTsTqSJ 9Saa 61F ffjD1wi1E6egT W5kPWYzB 2HT7G5q_UM4CH As_jBpG0uR9t dnPR74xK...

result:

ok 10 test cases ok. (10 test cases)

Test #15:

score: 0
Accepted
time: 95ms
memory: 39652kb

input:

1
100000
OZeDY6m2v P 0 accepted
DolcP A 0 accepted
2Z9Yd M 0 rejected
Vjl F 0 accepted
SPetC8_ru4S3nXJkkD C 0 rejected
XhLC G 0 rejected
wZvhcns7t7EaOero E 0 accepted
HRqRKcO87 I 0 rejected
dwfT7D H 0 rejected
cxvYaN8zSMGpoa9Q9xv U 0 accepted
nvXlrCa1zbx8uokfd T 0 accepted
E_bbU5C9bgpD_wGo P 0 rejec...

output:

213
MGjFY C43v3R4b8LW3Q9 mfyehHY0Z oSiFwlfMwcS3jpkr2 rNd4dEHrSQG ILnoUL _awjT Ak1 fWb7IydN_gKzO2taC KFVkidNTwOdQjL Fs9IUxeK3shPCoujX9Q vjVt Lsm BFz7FBsJB J0eHK1KxAeqQkS AUy I8kswCMax57Ik yExemmGQBoLWHTR kj1hskCNFa 4Va0Qz3xegJa1YTzfwB QIG9FWFdyGBjW QudpmL DeT1w3AJ 6u XU8Ig emPv UdMRp8X 4dQZ7VRS3v8lyV...

result:

ok 1 test cases ok. (1 test case)

Test #16:

score: 0
Accepted
time: 17ms
memory: 3612kb

input:

1
100000
A A 0 accepted
B Z 299 accepted
B Z 299 accepted
B A 299 rejected
B A 299 rejected
B A 299 rejected
B A 299 rejected
B A 299 rejected
B A 299 rejected
B A 299 rejected
B A 299 rejected
B A 299 rejected
B A 299 rejected
B A 299 rejected
B A 299 rejected
B A 299 rejected
B A 299 rejected
B A ...

output:

1
B

result:

ok 1 test cases ok. (1 test case)

Test #17:

score: 0
Accepted
time: 109ms
memory: 55516kb

input:

1
100000
qyGXWlwMuXY3212 A 20 accepted
l_IeEuuLy9 A 20 accepted
nlyFO0YOiDxyiNjBb A 20 accepted
8H A 20 accepted
ek A 20 accepted
Em63tewQVLljOUO4r A 20 accepted
AHdtZtwK8debApdvxMy8 A 20 accepted
l3aTB A 20 accepted
vyFuSSSLTV5yP A 20 accepted
uzPnnAXshwHCbl7 A 20 accepted
sL A 20 accepted
K099qoYV...

output:

99965
qyGXWlwMuXY3212 l_IeEuuLy9 nlyFO0YOiDxyiNjBb 8H ek Em63tewQVLljOUO4r AHdtZtwK8debApdvxMy8 l3aTB vyFuSSSLTV5yP uzPnnAXshwHCbl7 sL K099qoYVY2sT kck9cpgykQ7 2J1 ra2lVlNGy7f4RxRVM5 E33CcsmaRSM2V cxlks6lG8mJq 7mORI onTYGSrvdP51CMF Cc tUXXuc9 v0u27ogI6NDJt qCjpX_DEplHoejXdhrd nWeD_ Icwv_So VrSV_jfGx...

result:

ok 1 test cases ok. (1 test case)

Test #18:

score: 0
Accepted
time: 106ms
memory: 56988kb

input:

1
100000
xhmAFe A 20 accepted
loPCkhj2qt A 20 accepted
WIx A 20 accepted
T3zIPb A 20 accepted
xEEBg A 20 accepted
Gd0_zLXNJ1l1_Zrqa2 A 20 accepted
cM68n01suqhgjrBA A 20 accepted
LA6 A 20 accepted
AXBqy A 20 accepted
VLc4yxmdrN7S A 20 accepted
6p_z1vz2 A 20 accepted
wujWaUQNU0 A 20 accepted
eHIPyc0l3...

output:

99965
xhmAFe loPCkhj2qt WIx T3zIPb xEEBg Gd0_zLXNJ1l1_Zrqa2 cM68n01suqhgjrBA LA6 AXBqy VLc4yxmdrN7S 6p_z1vz2 wujWaUQNU0 eHIPyc0l3RHlajRl StgmAuYaQ 3 bc5_mjsU 48y2EwB1k0MDb uKwq9gQ2BX2jBrCO5dj MnbI Cbuup2jfG_e_S4Ass 9H1A9Mfu6K8lgut222o BCblgxpBBdAUvQkfgMQ S9mGs45VTW1ITX83dLy f3PRgkhpF464ONTioa ulbRGg...

result:

ok 1 test cases ok. (1 test case)

Extra Test:

score: 0
Extra Test Passed