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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

n = INT()
a = LIST()
a_front = []
a_back = []
 
flg = 1
for i in range(n):
	if flg == 1:
		a_back.append(a[i])
	else:
		a_front.append(a[i])
	flg *= -1

ans = a_front[::-1] + a_back
if flg == 1:
	print(*ans)
else:
	print(*ans[::-1])

Submission status: Accepted

Solution code:
n = int(input())
la = list(input().split())

if n % 2 == 0:
    l = list(reversed(la))[::2]
    l = l + la[::2]
    print(" ".join(l))

else:
    l = list(reversed(la))[::2]
    l = l + la[1::2]
    print(" ".join(l))

Submission status: Accepted

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

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

print(' '.join(ans))

Submission status: Accepted

Solution code:
from collections import deque

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]
  
print(" ".join(map(str,ANS)))

Submission status: Accepted

Solution code:
n = int(input())
A = list(input().split())
if n % 2:
    print(" ".join(A[::2][::-1]), " ".join(A[1::2]))
else:
    print(" ".join(A[1::2][::-1]), " ".join(A[::2]))

Submission status: Accepted

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


n = int(input())
A = input().split()
if n%2==0:
    print(' '.join(A[1::2][::-1]),end=' ')
    print(' '.join(A[::2]))
else:
    print(' '.join(A[::2][::-1]),end=' ')
    print(' '.join(A[1::2]))

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
as_ = map(int, input().strip().split())

d = deque()

reversed = False
for a in as_:
    if reversed:
        d.appendleft(a)
    else:
        d.append(a)
    reversed = not reversed

if reversed:
    d.reverse()

ans = ' '.join(map(str, d))

print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import deque

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))

res = deque()
t = (N + 1) % 2

for i in range(N):
    if i % 2 == t:
        res.appendleft(A[i])
    else:
        res.append(A[i])

print(*res)

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:
import collections

N = int(input())
A = list(map(int, input().split()))
ans = collections.deque()
for i in range(N):
    if N % 2 == 0:
        if i % 2 == 0:
            ans.append(A[i])
        else:
            ans.appendleft(A[i])
    else:
        if i % 2 == 0:
            ans.appendleft(A[i])
        else:
            ans.append(A[i])
print(*ans)

Submission status: Accepted

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

B = ['_' for _ in range(N)]
if N % 2 == 0:
    for i, a in enumerate(A):
        if i % 2 == 0:
            B[N//2 + i//2] = a
        else:
            B[N//2 - (i+1)//2] = a
else:
    for i, a in enumerate(A):
        if i % 2 == 0:
            B[N//2 - i//2] = a
        else:
            B[N//2 + (i+1)//2] = a

print(' '.join(B))

Submission status: Accepted

Solution code:
n = int(input())
a = input().split()
a_odd  = []
a_even = []
for i in range(n):
    if (i+1)%2 == 0:
        a_even.append(a[i])
    else:
        a_odd.append(a[i])
        
if n%2 == 0:
    print(" ".join(a_even[::-1] + a_odd))
else:
    print(" ".join(a_odd[::-1] + a_even))

Submission status: Accepted

Solution code:
# dequeでいくわ
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])
if n % 2 == 1:
    ans = list(ans)[::-1]
print(" ".join(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])
else:
    if n%2==0:
        b = list(b)
        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()
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_even = [elm_a for i, elm_a in enumerate(a) if i % 2 == 0]
a_odd = [elm_a for i, elm_a in enumerate(a) if i % 2 == 1]

ans = a_even[::-1] + a_odd
if n % 2 == 0:
  ans = ans[::-1]

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

Submission status: Accepted

Solution code:
# C - pushpush
# https://atcoder.jp/contests/abc066/tasks/arc077_a

from collections import deque

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

b = deque(maxlen=n)

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)

Submission status: Accepted

Solution code:
import sys
from collections import deque


n = int(sys.stdin.readline().strip())
A = map(int, sys.stdin.readline().strip().split())

q = deque()
for i, a_i in enumerate(A):
    if i % 2 == 0:
        q.append(a_i)
    else:
        q.appendleft(a_i)

ans = list(map(str, q))
if n % 2 == 1:
    ans = ans[::-1]

print(" ".join(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
odd=[];eve=[]
for i in range(n):
    if i%2==1:
        eve.append(lis[i])
    else:
        odd.append(lis[i])
if n%2==0:
    eve=list(reversed(eve))
    for s in eve:
        print(s,end=" ")
    for t in odd:
        print(t,end=" ")
else:
    odd=list(reversed(odd))
    for s in odd:
        print(s,end=" ")
    for t in eve:
        print(t,end=" ")

Submission status: Accepted

Solution code:
def main():
    from collections import deque

    N = int(input())
    A = input().split()

    ret = deque()
    head_is_0 = 1
    for x in A:
        if head_is_0:
            ret.append(x)
        else:
            ret.appendleft(x)
        head_is_0 ^= 1

    if head_is_0 == 0:
        ret.reverse()
    print(*ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = input().split()
R = []
L = []
for i,a in enumerate(A):
    if i%2 == 0:
        R.append(a)
    else:
        L.append(a)
ans = list(reversed(L))+R
if N%2 == 0:
    print(' '.join(ans))
else:
    print(' '.join(list(reversed(ans))))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    A = input().split()
    ans = list(reversed(A[1::2])) + A[::2]
    if n % 2 == 0:
        print(' '.join(ans))
    else:
        print(' '.join(list(reversed(ans))))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def make_indices_list(n):
  """
  Args:
    n (int)

  >>> make_indices_list(8):
  [7, 5, 3, 1, 0, 2, 4, 6]
  >>> make_indices_list(7):
  [6, 4, 2, 0, 1, 3, 5]
  """
  if n % 2 == 0:
    return list(range(n-1, 0, -2)) + list(range(0, n, 2))
  else:
    return list(range(n-1, -1, -2)) + list(range(1, n-1, 2))
    


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

indices_list = make_indices_list(n)
for ind in indices_list:
  print(L[ind], end=' ')
print('')

Submission status: Accepted

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

b = deque()

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

print(' '.join(b))

Submission status: Accepted

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

odd = []
even = []
for i in range(n):
    if i%2 == 0:
        odd.append(s[i])
    else:
        even.append(s[i])
    
if n%2 == 1:
    ans = odd[::-1] + even
else:
    ans = even[::-1] + odd
    
ans_str=[str(a) for a in ans]
print(" ".join(ans_str))

Submission status: Accepted

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

odd = []
even = []
for i in range(n):
    if i%2 == 0:
        odd.append(s[i])
    else:
        even.append(s[i])
    
ans = odd[::-1] + even
ans_str=[str(a) for a in ans]

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

Submission status: Accepted

Solution code:
from collections import deque

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

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

if len(a)%2 == 0:
  B = ' '.join(b)
  print(B)
else:
  b.reverse()
  B = ' '.join(b)
  print(B)

Submission status: Accepted

Solution code:
from collections import deque
n=int(input())
a=list(map(str,input().split()))
b=deque()
#print(b)
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(b))

Submission status: Accepted

Solution code:
from collections import deque


def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    que = deque()
    for i, a in enumerate(A):
        if (i + 1) % 2 == 1:
            que.append(a)
        else:
            que.appendleft(a)
    ans = list(que)
    if N % 2 == 1:
        ans.reverse()
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

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

d = deque()

for i in range(n):
    if n%2 == 0 and i%2 == 0:
        d.append(a[i])
    elif n%2==1 and i%2==1:
        d.append(a[i])
    else:
        d.appendleft(a[i])
print(' '.join(map(str,list(d))))

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
*a, = 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([str(v) for v in b]))

Submission status: Accepted

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

Submission status: Accepted

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

from collections import deque
b = []
b = deque(b)

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

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

Submission status: Accepted

Solution code:
N = int(input())
a = []
b = []
C = 0
A = list(map(int,input().split()))
for i in range(N):
    if i%2 == N%2:
      a.append(A[i])
    else:
      b.append(A[i])
b.reverse()
ans = ""
for i in range(len(b)):
  ans += str(b[i])
  ans += " "
for i in range(len(a)):
  ans += str(a[i])
  if i != len(a)-1:
    ans += " "
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

#input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
b=[0]*((n+1)//2)
c=[0]*(n//2)

for i in range((n+1)//2):
    b[i]=a[i*2]
for i in range(n//2):
    c[i]=a[i*2+1]
c.reverse()
c.extend(b)
if n%2==1:
    c.reverse()
print(*c)

Submission status: Accepted

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

odd = [v for i, v in enumerate(a[1:]) if i % 2 == 1]
even = [v for i, v in enumerate(a[1:]) if i % 2 == 0]

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

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

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:
        right.append(A[i])
    else:
        left.append(A[i])

if n%2==1:
    ans=right[::-1]+left
    
else:
    ans=left[::-1]+right
##print(left, right)
#print(ans)
print(*ans)

Submission status: Accepted

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

a = list(range(1,N+1,2))
b = list(range(2,N+1,2))

if N%2 == 0:
    b.reverse()
    ind = b + a
else:
    a.reverse()
    ind = a + b

ans = []
for i in ind:
    ans.append(A[i-1])

print(*ans)

Submission status: Accepted

Solution code:
def resolve():
    from collections import deque
    n = int(input())
    a = list(map(int, input().split()))
    trans = False
    ans = []
    ans = deque(ans)
    for i in range(n):
        add = a[i]
        if not trans:
            ans.append(add)
        else:
            ans.appendleft(add)
        trans = not trans
    if trans:
        ans = list(ans)[::-1]
    print(*ans)
resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from queue 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])

ans = list(b)

if n%2 != 0:
    ans = ans[::-1]

print(*ans)

Submission status: Accepted

Solution code:
from collections import deque
 
N = int(input())
numbers = input().split()
 
d = deque()
 
for i in range(N):
    if i % 2 == 0:
        d.append(numbers[i])
    else :
        d.appendleft(numbers[i])
        
if N % 2 == 1:
    d.reverse()
    
output = ' '.join(d)
 
print(output)

Submission status: Accepted

Solution code:
import sys
# import numpy as np
from collections import Counter, deque

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = deque(list(map(int, input().split())))
    B = deque([])

    if n % 2 == 0:
        for i in range(n):
            a = deque.popleft(A)
            if i % 2 == 0:
                B.append(a)
            else:
                B.appendleft(a)
    else:
        for i in range(n):
            a = deque.popleft(A)
            if i % 2 != 0:
                B.append(a)
            else:
                B.appendleft(a)
    print(" ".join(map(str, B)))


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
import sys
from collections import Counter
from collections import deque
import math
import fractions
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=list(map(str,input().split()))
ans=deque()
for i in range(n):
    if i%2==0:
        ans.append(a[i])
    else:
        ans.appendleft(a[i])
if n%2==1:
    ans=reversed(ans)
print(*ans)

Submission status: Accepted

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

ok = True
for i in range(n):
  if ok:
    b.append(a[i])
    ok = False
  else:
    b.appendleft(a[i])
    ok = True

b = list(map(str, list(b)))
if ok:
  print(" ".join(b))
else:
  print(" ".join(b[::-1]))

Submission status: Accepted

Solution code:
from collections import deque

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

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

print(*ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

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

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

Submission status: Accepted

Solution code:
from collections import deque

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

for i in range(n):
    if i % 2 == 0:
        que.appendleft(A[i])
    else:
        que.append(A[i])
else:
    if n % 2 == 0:
        que.reverse()
    lis = list(map(lambda x:str(x),que))
    print(" ".join(lis))

Submission status: Accepted

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

Submission status: Accepted

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

res = [0]*n
m = n //2

if n % 2 ==0:
    for i in range(m):
        res[i] = al[-1-i*2]    
    for j in range(m):
        res[m+j]= al[j*2]
           
else:
    for i in range(m+1):
        res[i] = al[-1-i*2]
    for j in range(m):
        res[m+1+j] = al[1+j*2]


ress=""
for k in range(n):
    ress +=str(res[k])
    ress +=" "

print(ress[:-1])

Submission status: Accepted

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

def resolve():
    n=int(input())
    a=list(input().split())
    akisu=a[0::2]
    agusu=a[1::2][::-1]
    b=agusu+akisu
    if n%2==0:
        print(*b)
    else:
        print(*b[::-1])
resolve()

Submission status: Accepted

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

odd = A[0::2]
even = A[1::2][::-1]

ans = even + odd

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

Submission status: Accepted

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

B = A[::2][::-1] + A[1::2]
if N % 2 == 0:
    B = B[::-1]
print(' '.join(B))

Submission status: Accepted

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

index = []
if N % 2 == 0:
    for i in range(N - 1, 0, -2):
        index.append(i)
    for j in range(0, N - 1, 2):
        index.append(j)
else:
    for i in range(N - 1, -1, -2):
        index.append(i)
    for j in range(1, N - 1, 2):
        index.append(j)

B = []
for i in index:
    B.append(str(A[i]))
print(' '.join(B))

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

Submission status: Accepted

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

Submission status: Accepted

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

b = []

if n % 2 == 0:
    for j in range(n-1, -1, -2):
        b.append(seq[j])
    for i in range(0, n, 2):
        b.append(seq[i])

else:
    for j in range(n-1, -1, -2):
        b.append(seq[j])
    
    for i in range(1, n, 2):
        b.append(seq[i])

print(' '.join(b))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
total = (n - 1) // 2
if n % 2 == 0:
    for i in range(n):
        div, mod = divmod(i, 2)
        if mod == 0:
            b[-total+div-1] = a[i]
        else:
            b[total-div] = a[i]
else:
    for i in range(n):
        div, mod = divmod(i, 2)
        if mod == 0:
            b[total - div] = a[i]
        else:
            b[-total+div] = a[i]

for i in range(n):
    print(b[i], end=' ')

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n = n//a
    count += 1
  if a**count == n:
    return count
  else:
    return count+1

#############
# Main Code #
#############

N = I()
A = IL()

iti = A[::2]
ni = A[1::2]

if N % 2:
  print(*((ni[::-1]+iti)[::-1]),sep=" ")
else:
  print(*(ni[::-1]+iti),sep=" ")

Submission status: Accepted

Solution code:
from collections import deque

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

reverse = False

ans = deque()
for i in a:
    if reverse:
        ans.appendleft(i)
    else:
        ans.append(i)
    reverse = not reverse

print(*reversed(ans)) if reverse else print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b1 = a[::2]
b2 = a[1::2]
if n % 2 == 1:
    b1 = b1[::-1]
    b1.extend(b2)
    b = b1
else:
    b2 = b2[::-1]
    b2.extend(b1)
    b = b2
print(*b, sep=' ')

Submission status: Accepted

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

if n % 2 == 1:
    left = a[0::2][::-1]
    right = a[1::2]
else:
    left = a[1::2][::-1]
    right = a[0::2]

ans = left + right

print(*ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N,*A=map(int,open(0).read().split())
print(*A[N-1::-2]+A[N&1::2])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
odd = []
even = []
o = 0
e = 1
while o < n:
  odd.append(str(a[o]))
  o += 2
while e < n:
  even.append(str(a[e]))
  e += 2
if n%2 == 0:
  ans = even[::-1]+odd
else:
  ans = odd[::-1]+even
print(' '.join(ans))

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
A = map(int, input().split())
B = deque()
flag = 0
for a in A:
  if flag:
    B.appendleft(a)
  else:
    B.append(a)
  flag = 1 - flag

B = list(B)
if flag:
  print(*B[::-1])
else:
  print(*B)

Submission status: Accepted

Solution code:
N = int(input())
A = list(input().split())
odd = []
even = []

for i in range(N):
    if i % 2 == 1:
        odd.append(A[i])
    else:
        even.append(A[i])

if N % 2 == 0:
    odd = odd[::-1]
    odd.extend(even)
    ans = odd
else:
    even = even[::-1]
    even.extend(odd)
    ans = even

print(" ".join(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    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])
    l=list(q)
    if n%2:
        l.reverse()
    print(*l)

if __name__ == '__main__':
    main()