AC043 in rust, finished all. (D doesn't get tested correctly locally)

This commit is contained in:
2022-05-28 14:58:05 +02:00
parent b378c4cb07
commit 97ee8adbf3
6 changed files with 141 additions and 0 deletions

View 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");
}