ABC 047, finished b and c
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user