https://atcoder.jp/contests/abc253/tasks/abc253_b
enumerateはこのようにするんですね。
for (i, s) in S.iter().enumerate() { ... }
// Distance Between Tokens #![allow(non_snake_case)] //////////////////// library //////////////////// fn read<T: std::str::FromStr>() -> T { let mut line = String::new(); std::io::stdin().read_line(&mut line).ok(); line.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>().split_whitespace() .map(|e| e.parse().ok().unwrap()).collect() } //////////////////// process //////////////////// fn get_points(S: &Vec<String>) -> Vec<(i32,i32)> { let mut v = Vec::<(i32,i32)>::new(); for (i, s) in S.iter().enumerate() { for (j, c) in s.chars().enumerate() { if c == 'o' { v.push((i as i32, j as i32)) } } } return v } fn main() { let v = read_vec(); let H: usize = v[0]; let S: Vec<String> = (0..H).map(|_| read()).collect(); let points = get_points(&S); assert!(points.len() == 2); let (i1, j1) = points[0]; let (i2, j2) = points[1]; let d = (i1 - i2).abs() + (j1 - j2).abs(); println!("{}", d) }