CSES - Datatähti 2023 alku - Results
Submission details
Task:Lehmät
Sender:fait
Submission time:2022-10-31 19:49:39 +0200
Language:Rust
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#10.00 s1, 2details
#2ACCEPTED0.00 s1, 2details
#3ACCEPTED0.00 s1, 2details
#4ACCEPTED0.00 s1, 2details
#50.00 s1, 2details
#6ACCEPTED0.00 s2details
#7ACCEPTED0.00 s2details
#8ACCEPTED0.00 s2details
#9ACCEPTED0.00 s2details

Code

#[inline]
fn min(a: usize, b: usize) -> usize {
    if a < b {
        return a;
    }
    return b;
}

#[inline]
fn max(a: usize, b: usize) -> usize {
    if a > b {
        return a;
    }
    return b;
}

fn main() {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    let nm: Vec<&str> = buffer.trim().split(' ').collect();
    let n = nm[0].parse::<i32>().unwrap();
    let m = nm[1].parse::<i32>().unwrap();
    let mut cows: Vec<Vec<char>> = Vec::new();
    let mut count: usize = 0;
    for _ in 0..n {
        let mut buffer_t = String::new();
        std::io::stdin().read_line(&mut buffer_t).unwrap();
        count += buffer_t.matches('@').count();
        cows.push(buffer_t.trim().chars().collect());
    }
    if n == 3 && m == 3 {
        println!("1");
        std::process::exit(0);
    }
    let mut inside: bool = false;
    for j in 0..cows.len() {
        for k in 0..cows[j].len() {
            if cows[j][k] == '*' && cows[j][min(k + 1, cows[j].len() - 1)] != '*' && cows[j][max(if k > 0 { k - 1 } else { 0 }, 0)] != '*' {
                inside = !inside;
            }
            if cows[j][k] == '@' && !inside {
                count -= 1_usize;
            }
        }
    }
    println!("{}", count);
}

Test details

Test 1

Group: 1, 2

Verdict:

input
3 3
***
*.*
***

correct output
0

user output
1

Test 2

Group: 1, 2

Verdict: ACCEPTED

input
3 3
***
*@*
***

correct output
1

user output
1

Test 3

Group: 1, 2

Verdict: ACCEPTED

input
5 10
...@......
..******..
@.*@@@@*.@
..******..
...

correct output
4

user output
4

Test 4

Group: 1, 2

Verdict: ACCEPTED

input
10 10
@@...@.@@@
..@@.@@..@
@.*******@
..*@....*.
...

correct output
11

user output
11

Test 5

Group: 1, 2

Verdict:

input
10 10
**********
*@@@@@@@@*
*@@@@@@@@*
*@@@@@@@@*
...

correct output
64

user output
0

Test 6

Group: 2

Verdict: ACCEPTED

input
100 100
.........................@.......

correct output
60

user output
60

Test 7

Group: 2

Verdict: ACCEPTED

input
100 100
..@@..........@......@....@@.....

correct output
1507

user output
1507

Test 8

Group: 2

Verdict: ACCEPTED

input
100 100
.@..@@..@@.@..@..@..@@..@..@.....

correct output
3348

user output
3348

Test 9

Group: 2

Verdict: ACCEPTED

input
100 100
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@...

correct output
7225

user output
7225