AC043 in rust, finished all. (D doesn't get tested correctly locally)
This commit is contained in:
44
atcoder/beginner_contests/abc043/src/bin/d.rs
Normal file
44
atcoder/beginner_contests/abc043/src/bin/d.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
use proconio::input;
|
||||
|
||||
fn main() {
|
||||
input!{
|
||||
s: String,
|
||||
};
|
||||
|
||||
let mut cs = s.chars();
|
||||
let l = s.len();
|
||||
|
||||
if l == 2 {
|
||||
let a = cs.next().unwrap();
|
||||
let b = cs.next().unwrap();
|
||||
|
||||
if a == b {
|
||||
println!("1 2");
|
||||
} else{
|
||||
println!("-1 -1");
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
let mut past_chars = [' '; 3];
|
||||
past_chars[1] = cs.next().unwrap();
|
||||
past_chars[2] = cs.next().unwrap();
|
||||
|
||||
for i in 2..l {
|
||||
past_chars[0] = past_chars[1];
|
||||
past_chars[1] = past_chars[2];
|
||||
past_chars[2] = cs.next().unwrap();
|
||||
|
||||
let mut sorting = [' '; 3];
|
||||
sorting.copy_from_slice(&past_chars);
|
||||
sorting.sort();
|
||||
|
||||
if sorting[0] == sorting[1] || sorting[1] == sorting[2] {
|
||||
println!("{} {}", {i-1}, {i+1});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
println!("-1 -1");
|
||||
}
|
||||
Reference in New Issue
Block a user