Task: | Lehmät |
Sender: | Mixu_78 |
Submission time: | 2022-11-05 22:22:48 +0200 |
Language: | Rust |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.00 s | 1, 2 | details |
#2 | WRONG ANSWER | 0.00 s | 1, 2 | details |
#3 | ACCEPTED | 0.00 s | 1, 2 | details |
#4 | ACCEPTED | 0.00 s | 1, 2 | details |
#5 | WRONG ANSWER | 0.00 s | 1, 2 | details |
#6 | ACCEPTED | 0.00 s | 2 | details |
#7 | ACCEPTED | 0.00 s | 2 | details |
#8 | ACCEPTED | 0.00 s | 2 | details |
#9 | ACCEPTED | 0.00 s | 2 | details |
Code
use std::io::{self, BufReader, BufRead}; fn main() { let stdin = io::stdin(); let buf = BufReader::new(stdin); let mut lines = buf.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 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 || y > end.0 { if line.find('*').is_none() { end = (y - 1, end.1); continue; } cows += line .chars() .enumerate() .fold(0, |acc, (i, c)| if i > start.1 && i < end.1 && c == '@' { acc + 1 } else { acc + 0 }); } } } println!("{cows}") }
Test details
Test 1
Group: 1, 2
Verdict: ACCEPTED
input |
---|
3 3 *** *.* *** |
correct output |
---|
0 |
user output |
---|
0 |
Test 2
Group: 1, 2
Verdict: WRONG ANSWER
input |
---|
3 3 *** *@* *** |
correct output |
---|
1 |
user output |
---|
0 |
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: WRONG ANSWER
input |
---|
10 10 ********** *@@@@@@@@* *@@@@@@@@* *@@@@@@@@* ... |
correct output |
---|
64 |
user output |
---|
56 |
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 |