Submission #2702214


Source Code Expand

use std::cmp;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.usize_read();
    let m = sc.usize_read();
    let a: Vec<Vec<usize>> = (0..n)
        .map(|_| (0..m).map(|_| sc.usize_read() - 1).collect())
        .collect();

    let mut ans = n;
    let mut dead = vec![false; m];
    for _ in 1..m {
        let mut count = vec![0; m];
        for a in &a {
            for &a in a {
                if dead[a] {
                    continue;
                }
                count[a] += 1;
                break;
            }
        }

        let max = *count.iter().max().unwrap();
        ans = cmp::min(ans, max);
        for (i, &a) in count.iter().enumerate() {
            if a == max {
                dead[i] = true;
            }
        }
    }

    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}

Submission Info

Submission Time
Task B - Sports Festival
User kenkoooo
Language Rust (1.15.1)
Score 0
Code Size 2802 Byte
Status WA
Exec Time 27 ms
Memory 4476 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 3
AC × 14
WA × 10
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt
Case Name Status Exec Time Memory
sample_01.txt AC 2 ms 4352 KB
sample_02.txt AC 2 ms 4352 KB
sample_03.txt AC 2 ms 4352 KB
subtask_1_01.txt AC 2 ms 4352 KB
subtask_1_02.txt AC 2 ms 4352 KB
subtask_1_03.txt WA 2 ms 4352 KB
subtask_1_04.txt WA 2 ms 4352 KB
subtask_1_05.txt AC 2 ms 4352 KB
subtask_1_06.txt WA 4 ms 4476 KB
subtask_1_07.txt AC 4 ms 4476 KB
subtask_1_08.txt AC 2 ms 4352 KB
subtask_1_09.txt AC 2 ms 4352 KB
subtask_1_10.txt WA 5 ms 4352 KB
subtask_1_11.txt WA 5 ms 4352 KB
subtask_1_12.txt WA 3 ms 4352 KB
subtask_1_13.txt WA 10 ms 4352 KB
subtask_1_14.txt WA 27 ms 4352 KB
subtask_1_15.txt AC 17 ms 4352 KB
subtask_1_16.txt WA 23 ms 4352 KB
subtask_1_17.txt WA 24 ms 4352 KB
subtask_1_18.txt AC 20 ms 4352 KB