ABC 047, finished b and c

This commit is contained in:
2022-06-07 14:10:25 +02:00
parent f631e0bfdc
commit a2acadbf3e
2 changed files with 52 additions and 8 deletions

View File

@@ -1,5 +1,33 @@
use proconio::input;
fn main() {
todo!();
input!{
s: String,
};
let mut result = 0;
let mut white_segment;
let first = s.chars().next().unwrap();
if first == 'W' {
white_segment = true;
} else {
white_segment = false;
}
for c in s.chars() {
match c {
'W' => if !white_segment {
white_segment = true;
result += 1;
},
'B' => if white_segment {
result += 1;
white_segment = false;
},
_ => (),
}
}
println!("{}", result);
}