Task: | Lehmät |
Sender: | fait |
Submission time: | 2022-10-31 19:53:13 +0200 |
Language: | Rust |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 28 |
#2 | ACCEPTED | 72 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.00 s | 1, 2 | details |
#2 | ACCEPTED | 0.00 s | 1, 2 | details |
#3 | ACCEPTED | 0.00 s | 1, 2 | details |
#4 | ACCEPTED | 0.00 s | 1, 2 | details |
#5 | ACCEPTED | 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 |
Compiler report
warning: unused variable: `m` --> input/code.rs:22:9 | 22 | let m = nm[1].parse::<i32>().unwrap(); | ^ help: if this is intentional, prefix it with an underscore: `_m` | = note: `#[warn(unused_variables)]` on by default warning: 1 warning emitted
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()); } let mut inside: bool = false; for j in 0..cows.len() { for k in 0..cows[j].len() { if cows[j][k] == '*' { if k == 0 && cows[j][k + 1] != '*' { inside = true; } else if 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; cows[j][k] = 'C'; } } } println!("{}", count); }
Test details
Test 1
Group: 1, 2
Verdict: ACCEPTED
input |
---|
3 3 *** *.* *** |
correct output |
---|
0 |
user output |
---|
0 |
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: ACCEPTED
input |
---|
10 10 ********** *@@@@@@@@* *@@@@@@@@* *@@@@@@@@* ... |
correct output |
---|
64 |
user output |
---|
64 |
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 |