AtCoder Beginner Contest 326 F

https://atcoder.jp/contests/abc326/tasks/abc326_f

奇数番目がy方向に正負のどちらにも行けるので、Aの奇数番目を足し引きしてYになればよいです。、偶数番目がx方向で同様です。
奇数番目を半分に分けると高々20なので、全ての足し引きの結果を得られるので、2つを足してYになるような組み合わせを探せばよいです。

// Robot Rotation
#![allow(non_snake_case)]

use std::collections::HashMap;


//////////////////// 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 read_input() -> (i32, i32, Vec<i32>) {
    let v: Vec<i32> = read_vec();
    let (X, Y) = (v[1], v[2]);
    let A = read_vec();
    (X, Y, A)
}

fn collect_coords(B: &[i32]) -> Vec<i32> {
    if B.len() == 0 {
        vec![0]
    }
    else if B.len() == 1 {
        vec![-B[0], B[0]]
    }
    else {
        let mid = B.len() / 2;
        let cs1 = collect_coords(&B[..mid]);
        let cs2 = collect_coords(&B[mid..]);
        cs2.iter().flat_map(|c2| cs1.iter().map(move |c1| c1 + c2)).
                                                    collect::<Vec<_>>()
    }
}

fn find_sum(x: i32, B: Vec<i32>) -> Option<usize> {
    let M = B.len();
    let mid = M / 2;
    let xs1 = collect_coords(&B[..mid]);
    let xs2 = collect_coords(&B[mid..]);
    let dic_xs1: HashMap<i32, usize> = xs1.iter().enumerate().
                                        map(|(i, &x)| (x, i)).collect();
    for (j, &x2) in xs2.iter().enumerate() {
        match dic_xs1.get(&(x - x2)) {
            Some(i) => return Some(i + (j << mid)),
            None    => ()
        }
    }
    None
}

fn find_sums(X: i32, Y: i32, A: Vec<i32>) -> Option<(usize, usize)> {
    let N = A.len();
    let AY: Vec<i32> = (0..N).step_by(2).map(|i| A[i]).collect();
    let AX: Vec<i32> = (1..N).step_by(2).map(|i| A[i]).collect();
    match (find_sum(Y, AY), find_sum(X, AX)) {
        (Some(n1), Some(n2)) => Some((n1, n2)),
        _                    => None
    }
}

fn print_dirs(n1: usize, n2: usize, N: usize) {
    let mut cs: Vec<char> = vec![];
    let mut cur_dir = 0;
    for i in 0..N {
        let j = i >> 1;
        let k = i & 1;
        let b = ((if k == 0 { n1 } else { n2 }) >> j) & 1;
        let old_dir = cur_dir;
        cur_dir = 3 - (b << 1) - k;
        cs.push(if ((cur_dir + 4 - old_dir) & 3) == 1 { 'L' } else { 'R' })
    }
    println!("{}", cs.into_iter().collect::<String>())
}

fn F(X: i32, Y: i32, A: Vec<i32>) {
    let N = A.len();
    match find_sums(X, Y, A) {
        Some((n1, n2)) => { println!("Yes"); print_dirs(n1, n2, N) },
        None           => println!("No")
    }
}

fn main() {
    let (X, Y, A) = read_input();
    F(X, Y, A)
}