CSES - Datatähti 2023 alku - Results
Submission details
Task:Lehmät
Sender:Mixu_78
Submission time:2022-11-05 22:16:38 +0200
Language:Rust
Status:COMPILE ERROR

Compiler report

error[E0658]: use of unstable library feature 'stdin_forwarders'
 --> input/code.rs:4:33
  |
4 |     let mut lines = io::stdin().lines();
  |                                 ^^^^^
  |
  = note: see issue #87096 <https://github.com/rust-lang/rust/issues/87096> for more information

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.

Code

use std::io;

fn main() {
    let mut lines = io::stdin().lines();
    let dim = lines.next().unwrap().unwrap();
    let mut split = dim.split(" ");

    let n: usize = split.next().unwrap().parse().unwrap();
    let m: usize = split.next().unwrap().parse().unwrap();

    let mut map: Vec<String> = Vec::with_capacity(n);
    let mut start: (usize, usize) = (0, 0);
    let mut end: (usize, usize) = (0, 0);
    let mut cows = 0;

    for y in 0..n {
        let line = lines.next().unwrap().unwrap();
        if start == (0, 0) {
            if let Some(x) = line.find('*') {
                start = (y, x);
                end = (n, line.rfind('*').unwrap())
            }
        } else {
            if y > start.0 {
                if line.find('*').is_none() {
                    end = (y - 1, end.1);
                }

                cows += line
                    .chars()
                    .enumerate()
                    .fold(0, |acc, (i, c)| if i > start.1 && i < end.1 && c == '@' { acc + 1 } else { acc + 0 });
            }
        }
    }

    println!("{start:?}, {end:?}, {cows}")
}