CSES - Datatähti 2023 alku - Results
Submission details
Task:Lehmät
Sender:fait
Submission time:2022-10-31 19:40:08 +0200
Language:Rust
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#10.00 s1, 2details
#20.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

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());
    }
    let mut inside: bool = false;
    for j in 0..cows.len() {
        for k in 0..cows[j].len() {
            if cows[j][k] == '*' && cows[j][std::cmp::min(k + 1, cows[j].len() - 1)] != '*' && cows[j][std::cmp::max(k - 1, 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
(empty)

Error:
thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 184467440737...

Test 2

Group: 1, 2

Verdict:

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

correct output
1

user output
(empty)

Error:
thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 184467440737...

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
(empty)

Error:
thread 'main' panicked at 'index out of bounds: the len is 10 but the index is 18446744073...

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