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:
#44 C - pushpush
n = int(input())
a = list(map(int,input().split()))

odd = [a[i] for i in range(n) if i%2 == 1] # O(n)
even = [a[j] for j in range(n) if j%2 == 0]# O(n)

if n%2 == 0:
    ans = list(reversed(odd)) + even # O(n)
else:
    ans = list(reversed(even)) + odd # O(n)
print(*ans)

Submission status: Accepted

Solution code:
from collections import deque

b=deque()

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

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]
b=[str(i) for i in b]

print(" ".join(b))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def INT():
    return int(input())

def MI():
    return map(int, input().split())

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

from collections import deque
n = INT()
a = LI()
b = deque()

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

Submission status: Accepted

Solution code:

n = int(input())
a = list(map(int,input().split()))
a = [0] + a

dam1=[]
dam2=[]
for i in range(1,n+1):
    if i%2==1:
        dam1.append(a[i])
    else:
        dam2.append(a[i])

if n%2==0:
    dam2.reverse()
    out=dam2 + dam1
elif n%2==1:
    dam1.reverse()
    out=dam1 + dam2
print(*out)

Submission status: Accepted

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

# 0
# 1, 0
# 2, 0, 1
# 3, 1, 0, 2
# 4, 2 ,0, 1, 3

front = []
back = []

for i in range(N):
  if i % 2 == 0:
    back.append(A[i])
  else:
    front.append(A[i])
    
ans = None
if N % 2 == 0:
  ans = front[::-1] + back
else:
  ans = back[::-1] + front
  
print(*ans)

Submission status: Accepted

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

# 0
# 1, 0
# 2, 0, 1
# 3, 1, 0, 2
# 4, 2 ,0, 1, 3

ans = None
if N % 2 == 1:
  ans = A[::2][::-1] + A[1::2]
else:
  ans = A[1::2][::-1] + A[::2]
print(*ans)

Submission status: Accepted

Solution code:
from collections import deque

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

d = deque()

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

if n%2==1:
    d.reverse()

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

Submission status: Accepted

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

if n == 1:
    l = list(map(str,l))
    print(" ".join(l))
    exit()

ans = []

if n%2 == 0:
    tmp = n
    for j in range(n//2-1):
        ans.append(tmp)
        tmp -= 2
    ans.append(tmp)
    ans.append(1)
    tmp = 1
    for j in range(n//2-1):
        tmp += 2
        ans.append(tmp)
else:
    tmp = n
    for j in range(n//2):
        ans.append(tmp)
        tmp -= 2
    ans.append(tmp)
    tmp = 2
    for j in range(n//2):
        ans.append(tmp)
        tmp += 2

ans2 = [0]*n
cnt = 0
for i in ans:
    ans2[cnt] = str(l[i-1])
    cnt += 1


print(" ".join(ans2))

Submission status: Accepted

Solution code:
import math

n = int(input())
aL = list(map(int, input().split(" ")))

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

if n % 2 == 0:
    print(*list(reversed([*reversed(l), *r])))
else:
    print(*reversed(l), *r)

Submission status: Accepted

Solution code:
from collections import deque

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

b = deque([])

if n % 2 == 0:
    flag = True
else:
    flag = False

for i in range(n):
    if flag:
        b.append(a[i])
        flag = not flag
    else:
        b.appendleft(a[i])
        flag = not flag

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
print(*A[::-2],*A[N%2::2])

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 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

if n % 2 == 1:
    b.reverse()

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

Submission status: Accepted

Solution code:
import collections
N = int(input())
lsa = list(map(str,input().split()))
lsb = collections.deque()
if N%2 == 0:
    for i in range(N):    
        if i % 2 == 0:
            lsb.append(lsa[i])
        else:
            lsb.appendleft(lsa[i])
if N%2 == 1:
    for i in range(N):
        if i % 2 == 1:
            lsb.append(lsa[i])
        else:
            lsb.appendleft(lsa[i])

print(' '.join(lsb))

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a = list(input().split())
q = deque()
for i in range(n):
    if n&1:
        if i&1:
            q.append(a[i])
        else:
            q.appendleft(a[i])
    else:
        if i&1:
            q.appendleft(a[i])
        else:
            q.append(a[i])

for i in q:
    print(i,end=" ")

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
from collections import deque
b = deque()
for i in range(N):
    if i%2==0:
        b.append(A[i])
    else:
        b.appendleft(A[i])
out = list(b)
if N%2==0:
    print(*out)
else:
    print(*out[::-1])

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 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n % 2 == 0:
    print(*list(b))
else:
    print(*list(b)[::-1])

Submission status: Accepted

Solution code:
from collections import deque

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

b = deque()

for i in range(1, n + 1):
    if i % 2 == 1:
        b.append(A[i - 1])
    else:
        b.appendleft(A[i - 1])

if n % 2 == 1:
    for i in range(n - 1, -1, -1):
        print(b[i], end='')
        if i != 0:
            print(' ', end='')
else:
    for i in range(n):
        print(b[i], end='')
        if i != n - 1:
            print(' ', end='')

Submission status: Accepted

Solution code:
'''
Created on 2020/08/28

@author: harurun
'''
def main():
  from collections import deque
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  n=int(pin())
  a=list(map(int,pin().split()))
  b=deque([])
  if n%2==0:
    for i in range(n):
      if i%2==0:
        b.append(a[i])
      else:
        b.appendleft(a[i])
  else:
    for j in range(n):
      if j%2==0:
        b.appendleft(a[j])
      else:
        b.append(a[j])
  for k in range(n):
    pout(str(b[k]))
    if k!=n-1:
      pout(" ")
  pout("\n")
  return 
main()

Submission status: Accepted

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

b = [-1] * n
l = 0
r = n-1
for i in range(n-1, -1, -1):
    if i % 2:
        b[l] = a[i]
        l += 1
    else:
        b[r] = a[i]
        r -= 1

if n % 2:
    b.reverse()
b = [str(i) for i in b]
print(' '.join(b))

Submission status: Accepted

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

Submission status: Accepted

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

a_even = a[0::2]
a_odd  = a[1::2] 

# even
if (n - 1) % 2 == 0: # 0-(n-1)の実施なので(n-1)の偶奇を判定
    b = a_even.copy()
    b.reverse()
    b = b + a_odd
# odd
else:
    b = a_odd.copy()
    b.reverse()
    b = b + a_even

b = list(map(str, b))
print(' '.join(b))

Submission status: Accepted

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

if n % 2 == 0:
    x = n//2
    for i in range(x):print(a[(n-1)-(2*i)])
    for i in range(x):print(a[2*i])
else:
    x = n//2 + 1
    for i in range(x):print(a[(n-1)-(2*i)])
    for i in range(x-1):print(a[(2*i)+1])

Submission status: Accepted

Solution code:
import collections

def f(myList):
    ans = ''
    if len(myList)%2==0:
        for i in range(len(myList)):
            ans += str(myList[i]) + ' '
    else:
        for i in range(len(myList)):
            ans += str(myList[-(i+1)]) + ' '
    return ans[:-1]

n = int(input())
a = list(map(int,input().split()))
b = collections.deque()
for i in range(n):
    if i%2==0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
print(f(b))

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
d=[]
s=[]
for i in range(n):
    if(i%2==0):
        d.append(l[i])
    else:
        s.append(l[i])
if(n%2==0):
    s.reverse()
    print(*(s+d))
else:
    d.reverse()
    print(*(d+s))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    A = input().split()
    evens = []
    odds = []
    for idx, a in enumerate(A, start=1):
        if idx % 2 == 0:
            evens.append(a)
        else:
            odds.append(a)

    if n % 2 == 0:
        evens.reverse()
        print((' ').join(evens + odds))
    else:
        odds.reverse()
        print((' ').join(odds + evens))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a=int(input()),list(map(int,input().split()))
print(*[a[1::2][::-1]+a[::2],a[0::2][::-1]+a[1::2]][n%2],sep=' ')

Submission status: Accepted

Solution code:
n,a=int(input()),list(map(int,input().split()))
b=[a[1::2][::-1]+a[::2],a[0::2][::-1]+a[1::2]][n%2]
print(*b,sep=' ')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

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

B=[0]*N

for i in range(N):
  if i<(N+1)//2:
    B[i]=A[N-1-2*i]
  else:
    B[i]=A[N-2*(N-i)]

print(*B)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(str, input().split()))
b = []
'''
b = [str(a[0])]
if (n == 1):
    print(a[0])
    exit()

a = a[1:]

for i in a:
    b.append(str(i))
    b.reverse()
'''
'''
loop = int(n / 2)
loop_rest = n - loop

for i in range(loop):
    tar_index = (n - 1) - 2 * i
    tar = a[tar_index]

    b.append(str(tar))


if (n % 2 == 0):
    tar_index = 0
else:
    tar_index = 1

for i in range(loop_rest):
    b.append(str(a[tar_index]))
    tar_index += 2
'''

# 一つおきでListを取る場合。
# a[0::2]
# 1つ目：起点。
# 2つ目：Step

# a[::-1]
# > -1step,つまりReverse

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

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a = list(map(int,input().split()))
b_1 = deque()
b_2 = deque()
switch = 0
for i in a:
    if switch == 0:
        b_1.append(i)
        b_2.appendleft(i)
        switch = 1
    else:
        b_2.append(i)
        b_1.appendleft(i)
        switch = 0
b_1 = list(b_1)
b_2 = list(b_2)
if switch == 0:
    print(' '.join(list(map(str,b_1))))
else:
    print(' '.join(list(map(str,b_2))))

Submission status: Accepted

Solution code:
import math
from collections import defaultdict,deque
from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""
t=1
#t=ii()
for _ in range(t):
    n=ii()
    a=ll()
    i=n-1;
    while(i>-1):
        print(a[i],end=" ")
        i-=2
    for i in range(n%2,n,2):
        print(a[i],end=" ")

Submission status: Accepted

Solution code:
n = int(input())
a = reversed(list(map(int, input().split())))
ans = [-1] * n
i = 0
for _a in a:
    if i % 2 == 0:
        ans[i // 2] = _a
    else:
        ans[-((i // 2) + 1)] = _a
    i += 1
for _ans in ans:
    print(_ans, end=" ")

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    n = I()
    a = LI()
    if n % 2 == 0:
        print(*a[::-2],*a[::2])
    else:
        print(*a[::-2],*a[1::2])
main()

Submission status: Accepted

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

b = [0]*N 

if N % 2 == 0:
    even = N//2
    odd = even - 1
    for i in range(N):
        if i % 2 == 0:
            b[even] = str(a[i])
            even += 1
        else:
            b[odd] = str(a[i])
            odd -= 1
else:
    even = N//2
    odd = even + 1
    for i in range(N):
        if i % 2 == 0:
            b[even] = str(a[i])
            even -= 1
        else:
            b[odd] = str(a[i])
            odd += 1

print(' '.join(b))

Submission status: Accepted

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

ans[n//2]=a[0]

#ケツから１こ飛ばしであたまからいれていく
for i in range(0,n//2,1):
    ans[i]=a[n-1-2*i]
    ans[n-1-i]=a[n-2-2*i]

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

Submission status: Accepted

Solution code:
n = int(input())
a_list = [int(x) for x in input().split()]
b = []
c = []
for i, a in enumerate(a_list):
    if i % 2 == 0:
        b.append(a)
    else:
        c.append(a)
if n % 2 == 0:
    d = list(reversed(c)) + b
else:
    d = list(reversed(b)) + c
print(*d)

Submission status: Accepted

Solution code:
n = int(input())
a = input().split()
b = [0] * n
for i in range(n):
    if i % 2 == 0:
        b[i//2] = a[n-1-i]
    else:
        b[n-(i+1)//2] = a[n-1-i]
print(' '.join(b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
A = [a for a in input().split(" ")]

if n == 1:
  print(A[0])
else:
  odd = A[::2]
  even = A[1::2]
  if n % 2 == 0:
    even.reverse()
    print(" ".join(even + odd))
  else:
    odd.reverse()
    print(" ".join(odd + even))

Submission status: Accepted

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

cnt = 0
b = []
c = []
for i in range(n):
  if i == 0:
    b.append(a[i])
  elif i % 2 == 0:
    b.append(a[i])
  elif i % 2 == 1:
    c.append(a[i])

if n % 2:
  ans = b[::-1] + c
else:
  ans = c[::-1] + b
print(*ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    inlis = list(map(int, input().split()))

    anslis = []
    for _ in range(n):
        anslis.append("")

    if n % 2 == 0:
        for i in range(n):
            if i < n // 2:
                a = -2 * i + n 
            else:
                a = (i - n //2) * 2 + 1
            anslis[i] = inlis[a-1]
    else:
        for i in range(n):
            if i < n // 2:
                a = -2 * i + n
            elif i == n // 2:
                a = 1
            else:
                a = (i - n//2) * 2
            anslis[i] = inlis[a-1]
    print(*anslis)






if __name__ == "__main__":
    main()

Submission status: Accepted

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

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:
import sys 
from collections import deque
N = int(input())
A = list(map(int, input().split()))


if N == 1:
    print(A[0])
    sys.exit()

mae = deque()
usiro = deque()

#0の時に前 1の時に後ろ
Flag = 0

for i in reversed(range(0,N,1)):
    
    if Flag == 0: # 前の時
        mae.append(str(A[i]))
        mae.append(" ")
        Flag = 1
    else:
        usiro.insert(0,str(A[i]))
        usiro.appendleft(" ")
        Flag = 0

moziretu = (mae + usiro)
del moziretu[((len(moziretu))//2)]
moziretu = ''.join(moziretu)
print(moziretu)

Submission status: Accepted

Solution code:
N=int(input())
l=list(map(int,input().split()))
p=[0]*N
for i in range(N):
  if i<(N+1)//2:
    p[i]=l[N-1-2*i]
  else:
    p[i]=l[N-2*(N-i)]
print(*p)

Submission status: Accepted

Solution code:
n = int(input())
a = [ int(x) for x in input().split() ]

l = []
if n % 2 == 1:
    i = n-1
    while i >= 0:
        l.append(a[i])
        i -= 2

    j = 1
    while j < n:
        l.append(a[j])
        j += 2
else:
    i = n-1
    while i >= 0:
        l.append(a[i])
        i -= 2

    j = 0
    while j < n:
        l.append(a[j])
        j += 2

print(' '.join(map(str, l)))

Submission status: Accepted

Solution code:
from collections import deque
n=int(input())
a=[int(x) for x in input().rstrip().split()]

ans=deque()
for i in range(n):
  if (i+1)%2==1:
    ans.appendleft(str(a[i]))
  else:
    ans.append(str(a[i]))

ans=list(ans)
if n%2==0:
  print(*ans[::-1])
else:
  print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
o = [a[i] for i in range(0,n,2)]
e = [a[h] for h in range(1,n,2)]
if n%2 == 0:
    e.reverse()
    l = e + o
    print(*l)
else:
    o.reverse()
    l = o + e
    print(*l)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
o = [a[i] for i in range(2,n,2)]
e = [a[h] for h in range(1,n,2)]
if n%2 == 0:
    e.reverse()
    l = e + [a[0]] + o
    print(*l)
else:
    o.reverse()
    l = o + [a[0]] + e
    print(*l)

Submission status: Accepted

Solution code:
# coding: utf-8
import math
from collections import deque
n = int(input())
#x, y = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
B = deque()
if n%2==0:
    for i in range(n):
        a=str(A[i])
        if i%2==1:
            B.appendleft(a)
        else:
            B.append(a)
if n%2==1:
    for i in range(n):
        a=str(A[i])
        if i%2==0:
            B.appendleft(a)
        else:
            B.append(a)
print(' '.join(B))

Submission status: Accepted

Solution code:
import sys
import math
from collections import deque


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
A = instrl()

B = deque()

if n % 2 == 0:
    for i in range(n):
        if i % 2 == 0:
            B.append(A[i])
        else:
            B.insert(0,A[i])
else:
    for i in range(n):
        if i % 2 == 0:
            B.insert(0,A[i])
        else:
            B.append(A[i])

print(" ".join(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 == 0:
        B.append(A[i])
    else:
        B.appendleft(A[i])
B = list(B)        
if n%2 != 0:
    B = B[::-1]
print(*B)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    A = deque(A)
    B = deque()
    if n % 2 == 0:
        while A:
            B.append(A.popleft())
            B.appendleft(A.popleft())
        B = list(B)
        print(*B)
    else:
        while len(A) != 1:
            B.append(A.popleft())
            B.appendleft(A.popleft())
        B.append(A.popleft())
        B = list(B)[::-1]
        print(*B)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc066/tasks/arc077_a
N = int(input())
N_List = list(map(str,input().split()))
if N % 2 == 0:
    ans = ' '.join(reversed(N_List[1::2])) + ' ' + ' '.join(N_List[::2])
else:
    ans = ' '.join(reversed(N_List[::2])) + ' ' + ' '.join(N_List[1::2])

print(ans)

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 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

if n % 2:
    b.reverse()
    
print(*b)

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
a = deque(list(map(int, input().split())))
b = deque() if n % 2 == 0 else deque([a.popleft()])
for _ in range(n // 2):
    b.append(a.popleft())
    b.appendleft(a.popleft())
print(*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==0:
    b.append(a[i])
  else:
    b.appendleft(a[i])
if n%2==0:
  print(*b)
else:
  print(*reversed(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:
    b.appendleft(a[i])
  else:
    b.append(a[i])
if n%2:
  print(*reversed(list(b)))
else:
  print(*list(b))

Submission status: Accepted

Solution code:
import collections
n,rev = int(raw_input()) ,False
class Node(object):
	def __init__(self, val):
		self.val = val
		self.next, self.prev = None, None

for i,ai in enumerate(map(int, raw_input().split())):
	node = Node(ai)		
	if i  == 0:
		head,tail = node,node
	else:
		if rev:
			head.prev, node.next = node, head
			head = node
		else:
			tail.next, node.prev = node, tail
			tail = node
		rev ^=  True

cur = head if not(rev) else tail  
while(cur):
	print cur.val, 
	cur = cur.next if not(rev) else cur.prev

Submission status: Accepted

Solution code:
import collections
n,rev,q = int(raw_input()) ,False,collections.deque()

class Node(object):
	def __init__(self, val):
		self.val = val
		self.next = None
		self.prev = None

head = None
tail = None
for ai in map(int, raw_input().split()):
	if head is None:
		node = Node(ai)
		head = node
		tail = node
	else:
		node = Node(ai)
		if rev:
			head.prev = node
			node.next= head
			head = node
		else:
			tail.next = node
			node.prev=  tail
			tail = node
		rev ^=  True

cur = head 
temp = []
while(cur):
	temp.append(cur.val)
	cur = cur.next 
print ' '.join(map(str, temp[::-1 if rev else 1]))

Submission status: Accepted

Solution code:
import collections
n,rev,q = int(raw_input()) ,False,collections.deque()

for ai in map(int, raw_input().split()):
	if rev: q.append(ai)
	else: q.appendleft(ai)
	rev ^= True

print ' '.join(map(str, list(q)[::1 if rev else -1]))

Submission status: Accepted

Solution code:
from collections import deque
q=deque()

n=int(input())
a=input().split()
for i in range(n):
    if i%2==0:
        q.append(a[i])
    else:
        q.appendleft(a[i])

if n%2==0:
    print(' '.join(q))
else:
    print(' '.join(list(q)[::-1]))

Submission status: Accepted

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

b_list = list(b)
if reverse == 1:
    print(*b_list)
else:
    print(*b_list[::-1])

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = [0 for _ in range(N)]
l = 0
r = N - 1
flg = 1
for i in range(N - 1, -1, -1):
    if flg:
        flg = 0
        ans[l] = A[i]
        l += 1
    else:
        flg = 1
        ans[r] = A[i]
        r -= 1
print(*ans)

Submission status: Accepted

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

even = [a[i] for i in range(1,n,2)]
odd = [a[i] for i in range(0,n,2)]

if n % 2 == 0:
  print(*(even[::-1]+odd))
else:
  print(*(odd[::-1]+even))

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 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

if n % 2 == 1:
    b.reverse()

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
A_odd = A[1::2]
A_even = A[::2]
if N%2 !=0:
 A_even = A_even[::-1]
 ans = A_even + A_odd
 for s in ans:
  print(s, end =" ")
else:
 A_odd = A_odd[::-1]
 ans = A_odd + A_even
 for s in ans:
  print(s, end =" ")

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
    if n%2:
        if i==n//2:
            b[i]=a[0]
        elif i<n//2:
            b[i]=a[n-i*2-1]
        else:
            b[i]=a[(i-n//2)*2-1]
    else:
        if i<n//2:
            b[i]=a[n-i*2-1]
        else:
            b[i]=a[(i-n//2)*2]
print(' '.join(map(str,b)))

Submission status: Accepted

Solution code:
from collections import deque
import sys
input = sys.stdin.buffer.readline


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

b = deque()

flag = True

if n % 2 == 1:
    flag = False
for a in A:
    if flag:
        b.append(a)
    else:
        b.appendleft(a)
    flag = not flag

print(" ".join((str(s) for s in b)))

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    if N % 2 == 0:
        B = A[1::2]
        B.reverse()
        B += A[0::2]
    else:
        B = A[0::2]
        B.reverse()
        B += A[1::2]
    print(" ".join(map(str, B)))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b0=[]
b1=[]
for i in range(n):
  if i%2==0:
    b0.append(a[i])
  else:
    b1.append(a[i])
if n%2!=0:
  b0=list(reversed(b0))
  b=b0+b1
  print(' '.join(map(str, b)))
else:
  b1=list(reversed(b1))
  b=b1+b0
  print(' '.join(map(str, b)))

Submission status: Accepted

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

from collections import deque
b = deque([])
for i, a in enumerate(A):
    if i % 2 == 0:
        b.append(a)
    else:
        b.appendleft(a)

if n % 2 == 0:
    print(*b)
else:
    print(*reversed(b))

Submission status: Accepted

Solution code:
n = int(input())
List = list(map(int,input().split()))
direction = 1
ahead = []
post = []
for i in range(n):
  if direction == 1:
    post.append(List[i])
  else:
    ahead.append(List[i])
  direction *= -1
if direction == 1:
  ans = ahead[::-1]+post
else:
  ans = post[::-1]+ahead
print(*ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a = list(map(int, input().split()))

q = deque()
t = 0
for i in a:
  if t == 0: q.append(i)
  else: q.appendleft(i)
  t = -1 - t
  
if t == 0: print(*q)
else: print(*reversed(q))

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
A = [int(c) for c in input().split()]
B = deque()

is_reversed = False
for a in A:
  if is_reversed:
    B.appendleft(a)
  else:
    B.append(a)
  is_reversed = not is_reversed

if is_reversed:
  ans = map(str, reversed(B))
else:
  ans = map(str, B)

print(' '.join(ans))

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
if n%2==0:
    print(' '.join([str(v) for v in l[1::2][::-1]+l[::2]]))
else:
    print(' '.join([str(v) for v in l[::2][::-1]+l[1::2]]))

Submission status: Accepted

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

even = []
odd = []

for i in range(0, n, 2):
    even.append(A[i])
for i in range(1, n, 2):
    odd.append(A[i])

if (n-1) % 2 == 0:
    even.reverse()
    ans = even + odd
else:
    odd.reverse()
    ans = odd + even

print(*ans)