Problem:
Score : 300 points

Problem Statement

You are given an integer sequence of length n, a_1, ..., a_n.
Let us consider performing the following n operations on an empty sequence b.

The i-th operation is as follows:

Append a_i to the end of b.

Reverse the order of the elements in b.

Find the sequence b obtained after these n operations.

Constraints

1 \leq n \leq 2\times 10^5

0 \leq a_i \leq 10^9

n and a_i are integers.

Input

Input is given from Standard Input in the following format:

n
a_1 a_2 ... a_n

Output

Print n integers in a line with spaces in between.
The i-th integer should be b_i.

Sample Input 1

4
1 2 3 4

Sample Output 1

4 2 1 3

After step 1 of the first operation, b becomes: 1.

After step 2 of the first operation, b becomes: 1.

After step 1 of the second operation, b becomes: 1, 2.

After step 2 of the second operation, b becomes: 2, 1.

After step 1 of the third operation, b becomes: 2, 1, 3.

After step 2 of the third operation, b becomes: 3, 1, 2.

After step 1 of the fourth operation, b becomes: 3, 1, 2, 4.

After step 2 of the fourth operation, b becomes: 4, 2, 1, 3.

Thus, the answer is 4 2 1 3.

Sample Input 2

3
1 2 3

Sample Output 2

3 1 2

As shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third operation. Thus, the answer is 3 1 2.

Sample Input 3

1
1000000000

Sample Output 3

1000000000

Sample Input 4

6
0 6 7 6 7 0

Sample Output 4

0 6 6 0 7 7

Solution in Rust (1.15.1) (judge verdict: Accepted)


#![allow(unused)]

use std::cmp;
use std::io::{self, BufRead};
use std::iter;
use std::collections::*;

macro_rules! destruct_ {
  ($e: expr, ()) => (
    //assert!($e.next().is_none())
  );
  ($e: expr, ($arg: ident, $( $args: ident )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args)*))
  );
  ($e: expr, ($arg: ident $( $args: ident )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args)*))
  );
}

macro_rules! split {
  ($e: expr, ($($name: ident)*)) => {
    let mut iter = $e.into_iter();
    destruct_!(iter, ($($name)*));
  }
}

macro_rules! gets {
  ($id: ident) => (
    let stdin = io::stdin();
    $id = Vec::new();
    for line in stdin.lock().lines() {
      $id.push(
        line
          .unwrap()
          .split_whitespace()
          .map(|a| a.parse().unwrap())
          .collect()
      );
    }
  )
}

macro_rules! get {
  ($id: ident) => (
    let stdin = io::stdin();
    $id = Vec::new();
    for line in stdin.lock().lines() {
      $id.push(
        line
          .unwrap()
          .parse().unwrap()
      );
    }
  )
}

macro_rules! p {
  ($a: expr) => (
    println!("{}", $a);
  )
}

macro_rules! pp {
  ($a: expr) => (
    println!("{:?}", $a);
  )
}

fn main() {
  let mut argss: Vec<Vec<i32>>;
  let mut ns;
  let mut n;
  let mut ls;
  gets!(argss);
  split!(argss, (ns ls));
  split!(ns, (n));

  //let mut s = String::new();
  //let mut b = if n % 2 == 0 { false } else { true };
  //for i in 0 .. (n as usize) {
  //  if 0 == i {
  //    s = ls[i].to_string();
  //  } else {
  //    if b {
  //      s.push_str(&format!(" {}", ls[i]));
  //    } else {
  //      s.insert(0, ' ');
  //      for c in ls[i].to_string().chars().rev() {
  //        s.insert(0, c);
  //      }
  //    }
  //    b = !b;
  //  }

  //}
  //p!(s);
  //

  let mut q = VecDeque::new();

  let mut b = if n % 2 == 0 { false } else { true };
  for i in 0 .. (n as usize) {
    if 0 == i {
      q.push_front(ls[i]);
    } else {
      if b {
        q.push_back(ls[i]);
      } else {
        q.push_front(ls[i]);
      }
      b = !b;
    }
  }


  for i in 0 .. (n as usize) {
    if i == ((n - 1) as usize) {
      println!("{}", q[i]);
    } else {
      print!("{} ", q[i]);
    }
  }
}