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:
from collections import deque
def solve():
  N = int(input())
  A = list(map(int, input().split()))
  ans = deque([])
  for i in range(N):
    if i%2==0:
      ans.append(A[i])
    else:
      ans.appendleft(A[i])
  ans = list(ans)
  if N%2==1:
    ans = ans[::-1]
  return ans
print(*solve())

Submission status: Accepted

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

left = []
right = []

for i in range(n):
    if i % 2 == 0:
        left.append(a[i])
    else:
        right.append(a[i])
if n % 2 == 0:
    right.reverse()
    arr = right + left
    ans = " ".join(map(str, arr))
    print(ans)
else:
    left.reverse()
    arr = left + right
    ans = " ".join(map(str, arr))
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a = list(map(int,input().split()))
ans = deque()
for k in range(n):
    if k%2 == 0:
        ans.append(a[k])
    else:
        ans.appendleft(a[k])

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

Submission status: Accepted

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import deque

n=int(input())
a=lnii()

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

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

print(*list(ans))

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
d = deque()
flag = False
for i in range(n):
    if flag:
        d.appendleft(A[i])
    else:
        d.append(A[i])
    flag = ~flag
if flag:
    d = reversed(d)
print(*d)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

b = deque()
for i,a in enumerate(A):
    if i%2:
        b.appendleft(a)
    else:
        b.append(a)

if N%2:
    print(*reversed(b))
else:
    print(*b)

Submission status: Accepted

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

a1 = []
a2 = []

for i in range(n):
    if i % 2 == 0:
        a2.append(a[i])
    else:
        a1.append(a[i])


if n % 2 != 0:
    #  偶数
    a2.reverse()
    res = a2 + a1

else:
    #  奇数
    a1.reverse()
    res = a1 + a2

[print(x, end=" ") for x in res]
print()

Submission status: Accepted

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

if n & 1:
  print(' '.join(a[::-2]+a[1::2]))
else:
  print(' '.join(a[-1:0:-2]+a[::2]))

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]

A.reverse()
ans = []

for i in range(0,N,2):
    ans.append(A[i])

A.reverse()

for i in range(N%2,N,2):
    ans.append(A[i])

[print(i,end=' ') for i in ans]

Submission status: Accepted

Solution code:
N = int(input())
A = input().split()
L = A[1::2]
R = A[0::2]
if N%2==0:
    print(' '.join(L[::-1]+R))
else:
    print(' '.join(R[::-1]+L))

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
A = list(map(int, input().split()))
B = deque([])
c = 1
for a in A:
  if c:
    B.append(a)
  else:
    B.appendleft(a)
  c = 1-c
if N%2:
  B.reverse()
print(*B)

Submission status: Accepted

Solution code:
N=int(input())
A=list(input().split())
if N%2==0:
  B=A[::-1]
  print(' '.join(B[::2])+' ' + ' '.join(A[::2]))
else:
  B=A[::-1]
  A=A[1::2]
  print(' '.join(B[::2])+' ' + ' '.join(A[:]))

Submission status: Accepted

Solution code:
from collections import deque
def main():
    n=int(input())
    x=deque()
    r=False
    for i in map(int,input().split()):
        if r:
            x.appendleft(i)
        else:
            x.append(i)
        r = not r
    if r:
        x.reverse()
    print(*x)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
a_lst = input().split()
odd = [a for i, a in enumerate(a_lst) if i % 2 != 0]
even = [a for i, a in enumerate(a_lst) if i % 2 == 0]

if n % 2 == 0:
  b = list(reversed(odd)) + even
else:
  b = list(reversed(even)) + odd
print(' '.join(b))

Submission status: Accepted

Solution code:
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    B = deque([])
    for i, a in enumerate(A):
        if i % 2 == N % 2:
            B.append(a)
        else:
            B.appendleft(a)

    print(*B)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

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

    if N % 2 != 0:
        B = reversed(B)

    print(*B)

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

kisu=[]
gusu=[]
for x in range(n):
  if (x+1)%2==1:
    kisu.append(a[x])
  else:
    gusu.append(a[x])
    
if n%2==0:
  gusu.reverse()
  ans=gusu+kisu
  
else:
  kisu.reverse()
  ans=kisu+gusu
  
ans1=[str(f) for f in ans]

ans1=' '.join(ans1)

print(ans1)

Submission status: Accepted

Solution code:
import sys
from collections import deque
finput=lambda: sys.stdin.readline().strip()

n=int(finput())
a=finput().split()
b=deque()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
A = deque(map(str, input().split()))
D = deque()
while A:
  x = A.popleft()
  D.append(x)
  if A:
    y = A.popleft()
    D.appendleft(y)
if n % 2 != 0:
  D.reverse()
print(" ".join(D))

Submission status: Accepted

Solution code:
n = int(input())
a = list(input().split())
b = []
a = a[::-1]
for i in range(n)[::2]:
    b.append(a[i])
a = a[::-1]
if n % 2 != 0:
    a.pop(0)
for i in range(len(a))[::2]:
    b.append(a[i])
print(' '.join(b))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
a = input().split()
ans = a[0::2][::-1] + a[1::2]
if n % 2:
    print(*ans)
else:
    print(*ans[::-1])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
A = deque(map(int, input().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 i in range(n):
        if i%2 ==0:
            b.appendleft(A[i])
        else:
            b.append(A[i])            
print(*b)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
head_s = [] 
back_s = []
n2 = 1
if n%2 == 0:
	n2 = 0
for h in range(n-1,-1,-2):
	head_s.append(a[h])
for b in range(n2,n,2):
	back_s.append(a[b])
#print(head_s,back_s)
ans_h = (' '.join(map(str,head_s)))
ans_b = (' '.join(map(str,back_s)))
print(ans_h,ans_b)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
r = []
l = []
for i in range(n):
  if i % 2 == 0:
    r.append(a[i])
  else:
    l.append(a[i])

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

Submission status: Accepted

Solution code:
from collections import deque

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

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

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

Submission status: Accepted

Solution code:
from collections import *
n = int(input())
a = [int(i) for i in input().split()]

b = deque()

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

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

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

Submission status: Accepted

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


resolve()

Submission status: Accepted

Solution code:
# C - pushpush
n = int(input())
a = list(map(str,input().split()))

b = [""]*n
var = 0

if n % 2 == 0:
    for i in range(n):
        res = a[i]
        var += i*(-1)**i
        ind = n//2 + var
        b[ind] = res
else:
    for i in range(n):
        res = a[i]
        var += i*(-1)**i
        ind = n//2 - var
        b[ind] = res

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

if n%2==0:
    b=list(b)[::-1]

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==1:
    b = list(b)[::-1]
print(' '.join(list(map(str, b))))

Submission status: Accepted

Solution code:
#!/usr/bin/env python

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

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

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

Submission status: Accepted

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

from collections import deque

q = deque([])

for i in range(N):
  if i % 2:
    q.appendleft(A[i])
  else:
    q.append(A[i])
    
if N % 2:
  q = list(q)[::-1]
  
print(*q)

Submission status: Accepted

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

if n % 2 == 0:
    b = a[n - 1 : 0 : -2] + a[0 : n - 1 : 2]
else:
    b = a[n - 1 : : -2] + a[1 : n - 1 : 2]

print(*b)

Submission status: Accepted

Solution code:
n,*a = map(int, open(0).read().split())
ans = [0] * n
for i in range(1,n+1):
    if i % 2 == 1:
        ans[i//2] = a[-i]
    else:
        ans[-(i//2)] = a[-i]
print(*ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

X=[A[i] for i in range(0,N,2)]
Y=[A[i] for i in range(1,N,2)]

if N%2:
    A=X[::-1]
    B=Y
else:
    A=Y[::-1]
    B=X

print(" ".join(map(str,A+B)))

Submission status: Accepted

Solution code:
from collections import deque
n=int(input())
a=list(map(int,input().split()))
ans=deque()
rev=False
if n&1:
   rev=True 
for i in a:
    if rev:
        ans.appendleft(i)
    else:
        ans.append(i)
    rev=not rev
print(*ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a_list = [int(x) for x in input().split()]
left_flag = n % 2 == 1
d = deque()
for a in a_list:
    if left_flag:
        d.appendleft(a)
    else:
        d.append(a)
    left_flag = not left_flag
print(*d)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

from collections import deque
Q = deque()
for i, a in enumerate(As):
    if i%2==0:
        Q.append(a)
    else:
        Q.appendleft(a)

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

Submission status: Accepted

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import deque

n=int(input())
a=lnii()

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

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

print(*ans)

Submission status: Accepted

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

flag = True

for x in a:
    if flag:
        b.append(x)
        flag = False
    else:
        b.appendleft(x)
        flag = True
if flag:
    print(*b)
else:
    print(*list(b)[::-1])

Submission status: Accepted

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

if n % 2 == 0:
    lis1 = a[::2]
    lis2 = a[::-2]
    ans = lis2 + lis1
else:
    lis1 = a[::-2]
    lis2 = a[1::2]
    ans = lis1 + lis2
ans = map(str, ans)
print(' '.join(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
A = [int(a) for a in input().split()]

q = deque()
for i in range(N):
    if i%2 == 0:
        q.append(A[i])
    else:
        q.appendleft(A[i])

ans = list(q)
if N%2 == 1:
    ans.reverse()
print(*ans)

Submission status: Accepted

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

Q = deque([])
for i in range(N):
  if i%2 ==0 :
    Q.append(A[i])
  else:
    Q.appendleft(A[i])
#print(Q)
if N%2 == 0:
  print(*Q)
else:
  Q.reverse()
  print(*Q)

Submission status: Accepted

Solution code:
from collections import deque

def resolve():
  n = int(input())
  a = list(map(int, input().split()))
  d = deque()
  for i in range(n):
    if i % 2 == 0:
      d.append(a[i])
    else:
      d.appendleft(a[i])
  while len(d) > 0:
    if n % 2 == 0:
      print(d.popleft(), end=' ')
    else:
      print(d.pop(), end=' ')
  print('')
  return

if __name__ == "__main__":
  resolve()

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret

def solve():
    nn = getN()
    n = getList()
    d = deque()
    for i, num in enumerate(n):
        if i % 2 == 0:
            d.append(num)
        else:
            d.appendleft(num)

    if len(n) % 2 == 1:
        d.reverse()
    # print(d)
    print(*list(d))

def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Submission status: Accepted

Solution code:
n=int(input())
a=list(input().split())
if n > 3:
    ans=''
    ans += ' '.join(a[::-2])
    if n%2==0:
        ans += ' ' + ' '.join(a[0::2])
    else:
        ans += ' ' + ' '.join(a[1::2])
    print(ans)
else:
    ans=[]
    for i in range(n):
        ans.append(a[i])
        ans.reverse()
    print(' '.join(ans))

Submission status: Accepted

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

B_even = deque([A[0]])
if N > 1:
    B_add = deque([A[1],A[0]])

for a_idx in range(2,len(A)):
    if a_idx % 2 == 0 :
        B_even.appendleft(A[a_idx])
        B_even.append(A[a_idx-1])
    else:
        B_add.appendleft(A[a_idx])
        B_add.append(A[a_idx-1])
        
if (N-1) % 2 ==0:
    B = B_even
else:
    B = B_add
    
print(' '.join(map(str,B)))

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
A = list(input().split())
B= deque()

for i in range(n):
  if i % 2:
    B.append(A[i])
  else:
    B.appendleft(A[i])
  
if n % 2 == 0:
  B.reverse()
  
print(" ".join(B))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
x = []
y = []
for i in range(len(a)):
    if i%2==0:
        x.append(str(a[i]))
    else:
        y.append(str(a[i]))
if n%2==1:
    x = x[::-1]
    print(' '.join(x+y));exit()
else:
    y = y[::-1]
    print(' '.join(y+x));exit()

Submission status: Accepted

Solution code:
from collections import deque


def main():
    n = int(input())
    As = list(map(int, input().split()))
    left = deque([])
    right = deque([])
    if n % 2 == 0:
        for i in range(n):
            if i % 2 == 0:
                right.append(As[i])
            else:
                left.appendleft(As[i])
    else:
        for i in range(n):
            if i % 2 == 0:
                left.appendleft(As[i])
            else:
                right.append(As[i])

    left.extend(right)
    print(*left)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

b = a[1::2][::-1]+a[::2]
if len(a)%2==0:
    print(' '.join(b))
else:
    print(' '.join(b[::-1]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = deque()
    for i in range(n):
        if i % 2:
            b.appendleft(a[i])
        else:
            b.append(a[i])
    if n % 2:
        b.reverse()
    print(*b)


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

abc

"""

Submission status: Accepted

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

    q = deque()
    for i in range(n):
        if i % 2 == 0:
            q.append(A[i])
        else:
            q.appendleft(A[i])
    
    ans = list(q)
    if n % 2 != 0:
        ans.reverse()
    
    print(*ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
a = input().split()
b = deque()

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

Submission status: Accepted

Solution code:
from collections import deque

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

Submission status: Accepted

Solution code:
n = int(input())
a = input().split()
ar = list(reversed(a))
ans = []
if not n % 2:
  for i in range(0, n, 2):
    ans.append(ar[i])

  for i in range(0, n, 2):
    ans.append(a[i])

  print(' '.join(ans))
else:
  for i in range(0, n, 2):
    ans.append(ar[i])

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

  print(' '.join(ans))

Submission status: Accepted

Solution code:
import collections

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

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

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

print(" ".join([str(x) for x in b]))

Submission status: Accepted

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

left = []
right = []

if n % 2 == 0:
    for i in range(n):
        if i % 2 == 0:
            right.append(a[i])
        else:
            left.append(a[i])
    
    print(*(left[::-1]+right))
else:
    for i in range(n):
        if i % 2 == 0:
            left.append(a[i])
        else:
            right.append(a[i])
    
    print(*(left[::-1]+right))

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
a = readInts()

if len(a)%2==0:
	for i in range(len(a)-1,0,-2):
		print(a[i], end=" ")
	for i in range(0,len(a),2):
		print(a[i], end=" ")
else:
	for i in range(len(a)-1,-1,-2):
		print(a[i], end=" ")
	for i in range(1,len(a),2):
		print(a[i], end=" ")

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[17]:


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


# In[19]:


if n%2 == 0:
    ans = list(reversed([a[i] for i in range(n) if i%2 != 0]))
    ans += [a[i] for i in range(n) if i%2 == 0]
else:
    ans = list(reversed([a[i] for i in range(n) if i%2 == 0]))
    ans += [a[i] for i in range(n) if i%2 != 0]
print(*ans)


# In[ ]:

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    B = [0 for a in A]
    mid = N // 2
    for i in range(0, N, 2):
        B[mid+i//2] = A[i]
    for i in range(1, N, 2):
        B[mid-(i+1)//2] = A[i]
    if N % 2 == 1:
        print(*B[::-1])
    else:
        print(*B)


if __name__ == '__main__':
    inputs = read()
    solve(*inputs)

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    import collections
    n = int(input())
    As = collections.deque([int(item) for item in input().split()])
    bs = collections.deque()

    for i in range(n):
        if i % 2 == 0:
            bs.append(As.popleft())
        else:
            bs.appendleft(As.popleft())
    res =list(bs)
    if n % 2 == 1:
        res.reverse()

    print(*res)




if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

ans = deque([])
t = 0
for i in a:
  if t == 0: ans.append(i)
  else: ans.appendleft(i)
  t = 1 - t

if t == 0: print(*ans)
else: print(*reversed(ans))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=[]
def ap(num1):
    ans.append(num1)
if n%2==0:
    num=n-1
    for i in range(n//2):
        ap(a[num])
        num-=2
    num=0
    for i in range(n//2):
        ap(a[num])
        num+=2
else:
    num=n-1
    for i in range(n//2+1):
        ap(a[num])
        num-=2
    num=1
    for i in range(n//2):
        ap(a[num])
        num+=2
print(*ans)

Submission status: Accepted

Solution code:
import sys
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    n = ii()
    a = list(mi())
    d = deque()
    for i in range(n):
        if i%2:
            d.appendleft(a[i])
        else:
            d.append(a[i])
    print(*list(d)[::((-1)**(n%2))])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import deque

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

res = deque()
for i in range(0, N-1, 2):
    res.append(A[i])
    res.appendleft(A[i+1])

if N % 2 == 1:
    res.append(A[N-1])
    print(" ".join(reversed([str(s) for s in res])))
else:
    print(" ".join(str(s) for s in res))

Submission status: Accepted

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

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

print(" ".join(q))

Submission status: Accepted

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

Submission status: Accepted

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

print(' '.join(res))

Submission status: Accepted

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

even=deque()
odd=deque()

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

ans=[]
while(len(odd)>0):
    ans.append(odd.pop())

while(len(even)>0):
    ans.append(even.popleft())

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

print(*ans)

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
A = deque(map(str, input().split()))
B = deque()
cycle = n % 2
for a in A:
    if cycle % 2 == 1:
        B.appendleft(a)
    else:
        B.append(a)
    cycle += 1
print(' '.join(B))