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



Sample input:
4
1 2 3 4


Sample output:
4 2 1 3

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 10 10:05:08 2019

@author: shinjisu
"""


# ARC 077 C
def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def dmp(x):
    global debug
    if debug:
        print(x)


def probC_TLE():
    N = getInt()
    A = getIntList()
    dmp((N, A))
    b = []
    for i in range(N):
        b.append(A[i])
        b.reverse()
        dmp(b)
    return b


def probC_TLE2():
    N = getInt()
    A = getIntList()
    dmp((N, A))
    former, latter = [], []
    for i in range(-1, -N-1, -1):
        if i % 2 == 0:
            latter = [A[i]] + latter
        else:
            former.append(A[i])
        full = former + latter
        dmp((former, latter, full))
    return full


def probC_TLE3():
    N = getInt()
    A = [x for x in input().split()]
    dmp((N, A))
    former, latter = '', ''
    for i in range(-1, -N-1, -1):
        if i % 2 == 0:
            latter = A[i] + ' ' + latter
        else:
            former = former + ' ' + A[i]
        dmp((former, latter))
    return former[1:] + ' ' + latter


def probC():
    N = getInt()
    A = getIntList()
    dmp((N, A))
    b = zeros(N)
    for i in range(-1, -N-1, -1):
        if i % 2 == 0:
            b[i//2] = A[i]
        else:
            b[-i//2] = A[i]
        dmp(b)
    return b


debug = False
# print(probC())
for n in probC():
    print(n, end=' ', flush=True)

Submission status: Accepted

Solution code:
INF, MOD = float("inf"), 1e9 + 7
MAX, MIN = -INF, INF
dx1, dy1, dx2, dy2 = [-1, 0, 1, 0], [0, -1, 0, 1], [-1, 0, 1, -1, 1, -1, 0, 1], [-1, -1, -1, 0, 0, 1, 1, 1]

def get_int():
    return int(input())

def get_int_list():
    return list(map(int, input().split()))

def mins(x, y):
    x = min(x, y)

def maxs(x, y):
    x = max(x, y)

while(True):
    try:
        n = get_int()
        a = get_int_list()
        print(*(a[::-2] + a[1::2]) if n % 2 else a[::-2] + a[::2])
    except EOFError:
        exit()

Submission status: Accepted

Solution code:
N = int(input())
A = list(input().split())

ans = []

l1 = A[0::2]
l2 = A[1::2]
if N % 2 == 0:
    l2 = l2[::-1]
    ans = l2+l1
else:
    l1 = l1[::-1]
    ans = l1+l2

print(" ".join(ans))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = []

l1 = A[0::2]
l2 = A[1::2]
if N % 2 == 0:
    l2 = l2[::-1]
    ans = l2+l1
else:
    l1 = l1[::-1]
    ans = l1+l2

print(" ".join(list(map(str, ans))))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = []
if N % 2 == 0:
    l1 = A[0::2]
    l2 = A[1::2]
    l2 = l2[::-1]
    ans = l2+l1
else:
    l1 = A[0::2]
    l2 = A[1::2]
    l1 = l1[::-1]
    ans = l1+l2

print(" ".join(list(map(str, ans))))

Submission status: Accepted

Solution code:
n = int(input())
a = list(int(i) for i in input().split())
aodd = []
aeven = []
for i in range(n):
 if i%2 == 1: aodd.append(a[i])
 else: aeven.append(a[i])
ans = []
if n%2 == 0:
  aeven.reverse()
  ans = aeven + aodd
else:
  aodd.reverse()
  ans = aodd+ aeven
ans.reverse()
  
print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
A = input().split(' ')

if n == 1:
    ans = A[0]
    print(ans)
    exit()
else:
    A_odd = A[::2]
    A_even = A[1::2]
    if n % 2 == 0:
        ans = A_even[::-1] + A_odd
    else:
        ans = A_odd[::-1] + A_even
    print(' '.join(ans))

Submission status: Accepted

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
br = []
if a % 2 == 0:
    for i in range(len(ar)-1,0,-2):
        br.append(ar[i])
    for i in range(0,len(ar)-1,+2):
        br.append(ar[i])
else:
    for i in range(len(ar)-1,-1,-2):
        br.append(ar[i])
    for i in range(1,len(ar)-1,+2):
        br.append(ar[i])
for i in range(a-1):
    print(str(br[i]),end = " ")
print(str(br[a-1]))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

if N % 2:
    index = list(range(N - 1, -1, -2)) + list(range(1, N, 2))
else:
    index = list(range(N - 1, 0, -2)) + list(range(0, N, 2))

print(*list(map(lambda i: A[i], index)))

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(N)]
if N%2==0:
    for i in range(N):
        B[N//2+(i//2+i%2)*((-1)**i)]=A[i]
else:
    for i in range(N):
        B[N//2+(i//2+i%2)*((-1)**(i+1))]=A[i]
for j in range(N):
    print(B[j], end=' ')
print()

Submission status: Accepted

Solution code:
def inpl(): return [int(i) for i in input().split()]
n = int(input())
a = inpl()
ans = [0 for _ in range(n)]
if n%2:
    for i,ai in enumerate(a):
        if i%2:
            ans[n//2+(i+1)//2] = ai
        else:
            ans[n//2-(i+1)//2] = ai
else:
    for i,ai in enumerate(a):
        if i%2:
            ans[n//2-(i+1)//2] = ai
        else:
            ans[n//2+(i+1)//2] = ai
print(*ans)

Submission status: Accepted

Solution code:
from collections import deque
n=int(input().strip())
a=list(map(int, input().split()))
b = deque()
for i in range(n):
    if i%2==0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
b=list(b)
if n%2==1:
    b=b[::-1]
print(' '.join(map(str, b)))

Submission status: Accepted

Solution code:

import sys
import collections
import math
from collections import Counter
from collections import deque

n = int(input())
A = [int(x) for x in input().split()]

Q = deque()

f = True
if n % 2 == 0:
    f = not f

for a in A:
    if f:
        Q.appendleft(a)
    else:
        Q.append(a)
    f = not f

print(" ".join([str(q) for q in Q]))

sys.exit(0)

Submission status: Accepted

Solution code:
import sys
import collections
import math

n = int(input())
A = [int(x) for x in input().split()]

R = [0] * n

idx = 0
for i in range(n-1, -1, -2):
    R[idx] = A[i]
    idx += 1

for i in range(n % 2, n, +2):
    R[idx] = A[i]
    idx += 1

print(" ".join([str(i) for i in R]))

sys.exit(0)

Submission status: Accepted

Solution code:
f = lambda: list(map(int,input().split()))
n = int(input())
a = f()
if n&1:
    b = a[::-2]+a[1::2]
else:
    b = a[::-2]+a[::2]
print(*b)

Submission status: Accepted

Solution code:
from collections import deque
N=int(input())
A=[i for i in input().split()]
s=deque()
s.append(A[0])
if N%2==1:
    for i in range(1,N):
        if i%2==1:
            s.append(A[i])
        else:
            s.appendleft(A[i])
else:
    for i in range(1,N):
        if i%2==0:
            s.append(A[i])
        else:
            s.appendleft(A[i])
print(' '.join(map(str,s)))

Submission status: Accepted

Solution code:
# cook your dish here
n = int(input())
a = list(map(int,input().split()))
c = []
d = []

for i in range(n):
    if i %2 == 0:
        c.append(a[i])
    else:
        d.append(a[i])
c = c[::-1]

b = c + d
c = b[::-1]
ass = ''
for i in range(n):
    if n %2 == 0:
        ass += str(c[i]) + ' '
    else:
        ass += str(b[i]) + ' '
print(ass)

Submission status: Accepted

Solution code:
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *
from heapq import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N = read()
A = reads()

ls = deque()
rev = False

for a in A:
  if rev:
    ls.appendleft(a)
  else:
    ls.append(a)
  rev = not rev

if rev:
  ls.reverse()

print(" ".join(str(x) for x in ls))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = input().split()
b = [a[0], []]
last = b[1]

for i in range(1,n):
    if i%2==0:
        last.append(a[i])
        last.append([])
        last = last[1]
    else:
        b = [a[i],b]

ret = []
for _ in range(n):
    ret.append(b[0])
    b = b[1]

if n%2==0:
    print(" ".join(ret))
else:

    print(" ".join(ret[::-1]))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))

if n % 2 == 1:
    b = a[::2]
    c = a[1::2]
    b.reverse()
    d = b+c
    print(' '.join(map(str,d)))
else:
    b = a[::2]
    c = a[1::2]
    c.reverse()
    d = c+b
    print(' '.join(map(str,d)))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b_1 = []
b_2 = []
b = []
for i in reversed(range(len(a))):
	if i % 2 != 0:
		b_1.append(a[i])
	else:
		b_2.append(a[i])
if len(a) % 2 == 0:
	b_2.reverse()
	b.extend(b_1)
	b.extend(b_2)
else:
	b_1.reverse()
	b.extend(b_2)
	b.extend(b_1)
for b_num in b:
	print(b_num, end = ' ')

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

b = []

for i in range(n-1, -1, -2):
	b.append(str(a[i]))

if n % 2 == 0:
	for i in range(0, n, 2):
		b.append(str(a[i]))
else:
	for i in range(1, n, 2):
		b.append(str(a[i]))

print(" ".join(b))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(str, input().split()))
ans = ""
if n % 2 == 0:
    for i in range(n-1, -1, -2):
        ans += a[i] + " "
    for i in range(0, n, 2):
        ans += a[i] + " "
else:
    for i in range(n-1, -1, -2):
        ans += a[i] + " "
    for i in range(1, n, 2):
        ans += a[i] + " "
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

A = list(input().split())

if N==1:
    print(A[0])
else:
    side1 = A[0::2]
    side2 = A[1::2]
    if N%2==0:
        print(" ".join(side2[::-1]+side1))
    else:
        print(" ".join(side1[::-1]+side2))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    n = int(input())
    a = list(map(str, input().split()))
    odd = a[::2]
    even = a[1::2]

    if n % 2 == 0:
        result = even[::-1] + odd
    else:
        result = odd[::-1] + even

    print(' '.join(result))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=[]
v=[]
ans=a[-1::-2]
if n%2==0:
    for i in range(0,n,2):
        v.append(a[i])
else:
    for i in range(1,n,2):
        v.append(a[i])
ans.extend(v)
moji=" ".join(map(str,ans))
print(moji)

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a = [int(i) for i in input().split()]
b = deque()
f = True
for i in range(n):
    if f: b.append(a[i])
    else: b.appendleft(a[i])
    f = not f
if i % 2 == 0: b.reverse()
print(*b)

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a = [int(i) for i in input().split()]
b = deque()
f = True
for i in range(n):
    if f: b.append(a[i])
    else: b.appendleft(a[i])
    f = not f
if i % 2 == 0: b.reverse()
print(*b)

Submission status: Accepted

Solution code:
def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(input())
def S(): return input()

n = I()
a = LI()
even = a[0::2]
odd = a[1::2]

if n % 2:
    ans = even[::-1]
    ans.extend(odd)
else:
    ans = odd[::-1]
    ans.extend(even)
for i in ans:
    print(i, end=" ")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N = int(input())
As = list(map(int, input().split()))
b = []
i = len(As) - 1
while i >= 0:
    b.append(As[i])
    i -= 2

i = len(As) % 2
while i<len(As):
    b.append((As[i]))
    i += 2

print(*b)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))

if n == 1:
	print(a[0])
elif n % 2 == 0:
	print(" ".join(map(str, a[1::2][::-1] + a[0::2])))
else:
	print(" ".join(map(str, a[0::2][::-1] + a[1::2])))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))

even = []
odd = []
for i in range(0,n):
	if i % 2 == 0:
		odd.append(a[i])
	else:
		even.append(a[i])

res = []
if n % 2 == 0:
	even = reversed(even)
	res.extend(even)
	res.extend(odd)
else:
	odd = reversed(odd)
	res.extend(odd)
	res.extend(even)

print(" ".join(map(str,res)))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

n = int(input())
A = inpl()

if n == 1:
    print(A[0])
else:
    if n % 2 == 0:
        print(" ".join(map(str, A[1::2][::-1] + A[::2])))
    else:
        print(" ".join(map(str, A[::2][::-1] + A[1::2])))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
INF = 10**100
r = range

class infix(object):
    def __init__(self, function):
        self.function = function

    def __ror__(self, other):
        self.left = other
        return self

    def __or__(self, other):
        return self.function(self.left, other)

    def __call__(self, value1, value2):
        return self.function(value1, value2)

@infix
def c(f_t_u, f_u_r): return lambda t: f_u_r(f_t_u(t))

class _Ap(object):
    def __rlshift__(self, other):
        self.value = other
        return self

    def __rshift__(self, other):
        return other(self.value)
Ap = _Ap()
A = Ap

#d = {1:2, 3:5, 6:10, 1000043:3814}
#zip(d.keys(), d.values())<<ap>>(list |c| sorted |c| reversed |c| list |c| print)

n=input()<<A>>int
a=map(int,input().split())
if n<=2:
    for i in range(n): 
        print(''.join(str(c)+' ' for c in a))
    exit()

index=[n//2]*n
if n%2:
    for i in range(n):
        index[i] += ((i+1)//2) * (+1 if i%2 else -1);
else:
    for i in range(n):
        index[i] += ((i+1)//2) * (-1 if i%2 else +1);
#print(index)

a=list(a)
ret=[0]*n
for i in range(n): 
    ret[index[i]]=a[i]
print(''.join(str(x)+' ' for x in ret))

Submission status: Accepted

Solution code:
from collections import deque
 
n = int(input())
a = list(map(int, input().split()))
 
b = deque()
 
for i in range(n):
    if i % 2 != n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
 
print(" ".join(map(str, b)))

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
a = list(map(int, input().split()))

b = deque()

for i in range(n):
    if i % 2 != n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])

print(" ".join(map(str, b)))

Submission status: Accepted

Solution code:
N = int(input())
a = input().split()
b = [""] * N
b1 = [a[i] for i in range(len(a)) if i % 2 == 1][::-1]
b2 = [a[i] for i in range(len(a)) if i % 2 == 0]
b = b1 + b2
if N % 2 == 1:
	b = b[::-1]
line = " ".join(b)
print(line)

Submission status: Accepted

Solution code:
#ARC077C

from collections import deque
d=deque()
n=int(raw_input())
a=raw_input().split()
for i in xrange(n):
 if i%2==n%2:
  d.append(a[i])
 else:
  d.appendleft(a[i])
for i in xrange(n):
 print d[i],
print

Submission status: Accepted

Solution code:
#!usr/bim/python
#! -*- coding: utf-8 -*-

import numpy as np

n = raw_input()
n = int(n)
a = raw_input()
a = a.split()

m = n/2
b = []

if n % 2 == 0:
    i = 0
    while i < m:
        b.append(a[2*(m-i)-1])
        i += 1
    i = 0
    while i < m:
        b.append(a[2*i])
        i += 1

else:
    i = 0
    while i <= m:
        b.append(a[2*(m-i)])
        i += 1
    i = 0
    while i < m:
        b.append(a[2*i+1])
        i += 1

for s in b:
    print s+" ",
print ""

Submission status: Accepted

Solution code:
N = int(input())
s = input().split()

# b = ''
# for ss in s:
#     b += ss
#     print(b)
#     b = b[::-1]
# print(" ".join(b))

ans = []
if N % 2 == 1:
    for ss in s[::-1][0::2]:
        ans.append(ss)
    for ss in s[1::2]:
        ans.append(ss)
else:
    for ss in s[::-1][0::2]:
        ans.append(ss)
    for ss in s[0::2]:
        ans.append(ss)
print(" ".join(ans))

Submission status: Accepted

Solution code:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

n = ri()
a = rli()
b = []

if(n%2 == 1):
    for i in range(0,n,2)[::-1]:
        b.append(a[i])
    for i in range(1,n,2):
        b.append(a[i])
else:
    for i in range(1,n+1,2)[::-1]:
        b.append(a[i])
    for i in range(0,n,2):
        b.append(a[i])
print(" ".join(list(map(str, b))))

Submission status: Accepted

Solution code:
input();A=input().split();print(*A[::-2]+A[len(A)%2::2])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
a = input().split()
l = []
r = []
for a_i in a:
    r += [ a_i ]
    l, r = r, l
print(*(list(reversed(l)) + r))

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
print(' '.join(map(str,A[::-2]))+' '+' '.join(map(str,A[len(A)%2::2])))

Submission status: Accepted

Solution code:
n = int(input())
a = list(input().split())
if n == 1:
    print(a[0])
elif n % 2:
    print(*(a[-1::-2] + a[1::2]))
else:
    print(*(a[-1::-2] + a[0::2]))

Submission status: Accepted

Solution code:
n = int(raw_input())
A = map(int, raw_input().split())

e = A[::2]
o = A[1::2]
ans = e[::-1] + o
if n % 2 == 0:
    ans = ans[::-1]
print " ".join(map(str, ans))

Submission status: Accepted

Solution code:
from math import floor

def c(n,x):
    ret = [-1] * n
    for i in range(n):
        if i%2 == 0: idx = floor(i/2) 
        else: idx = n - 1 - floor(i/2)
        ret[idx] = x[n-i-1] 
    return " ".join([str(i) for i in ret])

def main():
    n = int(input())
    x = list(map(int, input().split()))
    print(c(n,x))

def test():
    print( c(4,[1,2,3,4]))
    print( c(6,[0,6,7,6,7,0]))
main()

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    A = reversed(A)
    left = 0
    right = N - 1
    res = [0] * N
    for i,val in enumerate(A):
        if i % 2 == 0:
            res[left] = val
            left += 1
        else:
            res[right] = val
            right -= 1
    print(" ".join(map(str,res)))

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
l = list(map(int, input().split()))
d = deque()

for i in range(n):
  if (i % 2 == 0):
    d.appendleft(l[i])
  else:
    d.append(l[i])

if (n % 2 == 0):
  d = reversed(d)

print(" ".join(map(str, d)))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

ans = [-1 for i in range(n)]
for i in range(n):
    if i % 2 == 0:
        ans[i // 2] = a[n - i - 1]
    else:
        ans[n - (i // 2 + 1)] = a[n - i - 1]
print(' '.join(map(str, ans)))

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    A = reversed(A)
    left = 0
    right = N - 1
    res = [0] * N
    for i,val in enumerate(A):
        if i % 2 == 0:
            res[left] = val
            left += 1
        else:
            res[right] = val
            right -= 1
    print(" ".join(map(str,res)))

Submission status: Accepted

Solution code:
import math
inf=float('inf')
N = int(input())
x = list(map(int, input().split()))
y = [0]*(N)
j=0
for i in range(0,N,1):
    
    if i%2==0:
        y[j]=x[N-1-i]
  
    if i%2==1:
        y[N-1-j]=x[N-1-i]
        j+=1
    
    


for i in range(len(y)):
    print(y[i],end=' ')
 
quit()

Submission status: Accepted

Solution code:
n = int(input())
aa = list(map(int, input().split()))
if n == 1:
    print(aa[0])
elif n % 2:
    print(*(aa[-1::-2] + aa[1::2]))
else:
    print(*(aa[-1::-2] + aa[0::2]))

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ns = lambda: stdin.readline()
ni = lambda: int(ns())
na = lambda: list(map(int,stdin.readline().split()))

n = ni()
a = na()

l = []
m = []
for i, x in enumerate(a):
    if (i%2==1):
        l.append(x)
    else:
        m.append(x)

if (n%2==0):
    l.reverse()
    l.extend(m)
    ret = l
else:
    m.reverse()
    m.extend(l)
    ret = m

ans = ""
for i, x in enumerate(ret):
    ans += str(x)
    if (i!=n-1): ans += " "
    
print (ans)

Submission status: Accepted

Solution code:
n = int(input())
xs = list(map(int, input().split()))
ys = xs[-1::-2] + xs[n%2::2]
print(*ys)

Submission status: Accepted

Solution code:
input()
n=[x for x in input().split()]
nb=n[::-1]
bs=n[::2]
if len(nb)%2==0:
    be=nb[::2]
else:
    be=nb[1::2]
if len(n)==1:
    print(n[0])
else:
    ans=be+bs
    if len(n)%2!=0:
        ans=ans[::-1]
    print(" ".join(ans))

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = LI()
    a1 = a[0::2]
    a2 = a[1::2]
    r = []
    if n % 2 == 0:
        r = a2[::-1] + a1
    else:
        r = a1[::-1] + a2
    return ' '.join(map(str, r))


print(main())

Submission status: Accepted

Solution code:
n=int(raw_input())
N=map(int,raw_input().split())
a=[]
b=[]
for i in range(n):
    if i%2==0:
        a.append(N[i])
    else:
        b.append(N[i])
if n%2==0:
    b.reverse()
    for i in b+a:
        print i,
else:
    a.reverse()
    for i in a+b:
        print i,

Submission status: Accepted

Solution code:
n=int(input());A=input().split();print(*A[-1::-2]+A[n%2::2])

Submission status: Accepted

Solution code:
# coding: utf-8

import collections


def solve():
    n = int(input())
    qo = collections.deque()
    qe = collections.deque()

    for i, a in enumerate(map(int, input().split())):
        if i % 2 == 0:
            qe.append(a)
        else:
            qo.append(a)

    r = []

    if n % 2 == 0:
        while qo:
            r.append(qo.pop())
        while qe:
            r.append(qe.popleft())
    else:
        while qe:
            r.append(qe.pop())
        while qo:
            r.append(qo.popleft())
    print(" ".join(map(str, r)))


solve()

Submission status: Accepted

Solution code:
N=int(raw_input())
P=raw_input().split()
b=P[-1::-2]+P[N%2::2]
print " ".join(b)

Submission status: Accepted

Solution code:
n=int(input())
a=input().split()

for i in range(len(a)):
    a[i]=int(a[i])

b=[0 for i in range(len(a))]

if(n%2==0):
    for i in range(int(n/2)):
        b[i]=a[n-2*i-1]
    
    for i in range(int(n/2)):
        b[i+int(n/2)]=a[1+2*i-1]
else:
    for i in range(int((n+1)/2)):
        b[i]=a[n-2*i-1]
    for i in range(int((n-1)/2)):
        b[i+int((n+1)/2)]=a[2+2*i-1]
        
for i in range(n):
    print(b[i],end=" ")

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[]

if n%2==0:

    for i in range(n):

        if n-i*2-1 > 0:
            b.append(a[n-i*2-1])
        else:
            k=abs(n-i*2)
            b.append(a[k])

else:
    
    for i in range(n):

        if n-i*2-1 >= 0:
            b.append(a[n-i*2-1])
        else:
            k=abs(n-i*2-1)
            b.append(a[k-1])

print(*b)

Submission status: Accepted

Solution code:
read = lambda: map(int, input().split())
n = int(input())
a = list(read())
from collections import deque
b = deque()
x = 1
for i in range(n):
    if x: b.append(a[i])
    else: b.appendleft(a[i])
    x ^= 1
ans = list(b)
if not x: ans = ans[::-1]
print(*ans)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split(" ")))

a.insert(0,-1)

m=len(a)-1
res=""

k=m
for i in range(int(m/2)+1):
    res+=str(a[k])+" "
    k-=2
    if k<=0:
        break

if m%2==0:
    s=1
else:
    s=2

if m>1:
    k=s
    for i in range(int(m/2)+1):
        res+=str(a[k])+" "
        k+=2
        if k>=m:
            break

print(res)

Submission status: Accepted

Solution code:
n = int(input())
xs = [int(i) for i in input().split()]
if n == 1:
    print(xs[0])
else:
    output1 = [None] * (n // 2)
    output2 = [None] * (n // 2)
    suf = 1
    if n % 2 == 1:
        suf = 2
    for i in range(n // 2):
        output1[i] = xs[i*2]
        if -(-2 * i - suf) <= n:
            output2[i] = xs[-2 * i - suf]
    if n % 2 == 1:
        output1.append(xs[n - 1])
        output1.reverse()
        output2.reverse()
        print(" ".join([str(i) for i in (output1 + output2)]))
    else:
        print(" ".join([str(i) for i in (output2 + output1)]))

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3
# -*- coding: UTF-8 -*-

n=int(input())
l=[int(i) for i in input().split()]

ans=[]
if n%2:
    for i in range(n-1,-1,-2):
        ans.append(l[i])
    for i in range(1,n,2):
        ans.append(l[i])
else:
    for i in range(n-1,0,-1):
        if i%2:
            ans.append(l[i])
    for i in range(n-1):
        if i%2==0:
            ans.append(l[i])

print(*ans)

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
a = list(map(int, input().strip().split()))
b = deque()

for i in range(n):
    if i % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
else:
    if i % 2 == 0:
        b.reverse()

print(" ".join(list(map(str, b))))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

b = [0] * n

for i in range(n):
  if i < n/2:
    b[i] = a[(n-1) - (2*i)]
  else:
    b[i] = a[2*i - n]
print(' '.join(list(map(str, b))))

Submission status: Accepted

Solution code:
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    n = II()
    a = list(map(str, input().split()))
    return n, a


def solve(n, a):
    b = collections.deque([])
    if n % 2 == 0:
        for i, ele in enumerate(a):
            if i % 2 == 0:
                b.append(ele)
            else:
                b.appendleft(ele)
    else:
        for i, ele in enumerate(a):
            if i % 2 == 0:
                b.appendleft(ele)
            else:
                b.append(ele)

    ans = " ".join(list(b))
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

if __name__ == "__main__":
	n = int(input())
	num_array = input().split(" ")
	result = [0 for i in range(n)]
	for i in range(n)[::-1]:
		differ = n - (i + 1)
		if differ % 2 == 0:
			result[differ // 2] = num_array[i]
		else:
			result[- ((differ + 1) // 2)] = num_array[i]
	result_word = result[0]
	for w in result[1:]:
		result_word += " " + w
	print(result_word)

Submission status: Accepted

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
ans=[]
for i in range(0,n,2):
	ans.append(a[i])
ans.reverse()
for i in range(1,n,2):
	ans.append(a[i])
#print(ans)
if(n%2==0):
	for i in range(n):
		print(ans[n-i-1],end="")
		if(not i==n-1):
			print(" ",end="")
else:
	for i in range(n):
		print(ans[i],end="")
		if(not i==n-1):
			print(" ",end="")

Submission status: Accepted

Solution code:
import sys
from collections import deque

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    n = int(input_raw[0])
    input_raw = list(read_func().strip().split())
    b_list = deque([])
    is_last_first = False
    for i in range(n):
        is_last_first = not(is_last_first)
        if is_last_first == True:
            b_list.append((input_raw[i]))
        else:
            b_list.appendleft(input_raw[i])

    if is_last_first == True:
        b_list.reverse()
    print " ".join(b_list)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
import numpy as np

n=int(input())
a=np.array([int(i)  for i in input().split()])

b=np.zeros(n, dtype=int)
pos=math.ceil((n-1)/2)

forward=True
for i in range(n):
    #print("i:{0}, pos:{1}, a[i]:{2}".format(i, pos, a[i]))
    b[pos]=a[i]
    if forward:
        forward=False
        pos-=(i+1)
    else:
        forward=True
        pos+=(i+1)
        
if forward:
    for i in range(n):
        print(b[i],end=' ')
else:
    for i in range(n):
        print(b[n-1-i],end=' ')

Submission status: Accepted

Solution code:
import sys


# sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n = read_int()
    a = read_int_list()
    b = [0] * n
    p = 0
    q = n - 1
    for i in range(n-1, -1, -1):
        if i % 2 == (n-1) % 2:
            b[p] = a[i]
            p += 1
        else:
            b[q] = a[i]
            q += -1
    return ' '.join(map(str, b))


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(raw_input())
a=map(int,raw_input().split())

for i in range((n+1)/2):
    print a[n-2*i-1],
for i in range(n/2):
    print a[i*2+n%2],
print ''

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

b = []
if n % 2 == 0:
    for i in reversed(range(1, n, 2)):
        b.append(str(a[i]))
    for i in range(0, n, 2):
        b.append(str(a[i]))
else:
    for i in reversed(range(0, n + 1, 2)):
        b.append(str(a[i]))
    for i in range(1, n, 2):
        b.append(str(a[i]))

ans = ' '.join(b)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
As = list(map(int, input().split()))
ret = []
for a in range(n-1, 0-1, -2):
    ret.append(As[a])
for a in range(n%2, n-1, 2):
    ret.append(As[a])
print(' '.join(map(str,ret)))