Problem:


Insertion Sort

Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:

for i = 1 to A.length-1
    key = A[i]
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
    j = i - 1
    while j >= 0 and A[j] > key
        A[j+1] = A[j]
        j--
    A[j+1] = key

Note that, indices for array elements are based on 0-origin.

To illustrate the algorithms, your program should trace intermediate result for each step.

Input

The first line of the input includes an integer N, the number of elements in the sequence.

In the second line, N elements of the sequence are given separated by a single space.

Output

The output consists of N lines. Please output the intermediate sequence in a line for each step. Elements of the sequence should be separated by single space.

Constraints

1 ≤ N ≤ 100

Sample Input 1

6
5 2 4 6 1 3

Sample Output 1

5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6

Sample Input 2

3
1 2 3

Sample Output 2

1 2 3
1 2 3
1 2 3

Hint

Template in C



Sample input:
6
5 2 4 6 1 3


Sample output:
5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6

Submission status: Runtime Error

Solution code:
n = input()
A = map(int,raw_input().split())
 print A
for j in range(1,n):
    key = A[j]
    # insert A[j] into the sorted sequence A[1,...,j-1]
    i = j - 1
    while i >= 0 and A[i] > key:
       A[i+1] = A[i]
       i -= 1
    A[i+1] = key
    print A

Submission status: Runtime Error

Solution code:
def: isort(n,a):
    print " ".join(map(str, a))
    for j in range(1,n):
        key = a[j]
        i = j-1
        while i >= 0 and a[i] > key:
            a[i+1] = a[i]
            i = i - 1
        a[i+1] = key
        print " ".join(map(str, a))

n = int(raw_input())
a = map(int, raw_input().split())
isort(n,a)

Submission status: WA: Presentation Error

Solution code:
import sys

n = input()
sort_list = list()

sort_list = map(int, raw_input().split())

for i in range(0,n):
    
    
    tmp = sort_list[i]
    j = i - 1
    while j >= 0 and sort_list[j] > tmp:
        sort_list[j+1] = sort_list[j]
        j = j - 1

    sort_list[j+1] = tmp


    for k in range(0,n):
        sys.stdout.write(str(sort_list[k]))
        if k is not n - 1:
            sys.stdout.write(" ")
        elif i is not n - 1:
            sys.stdout.write("\n")

Submission status: WA: Presentation Error

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

for k in range(0,n):
      if k!=n-1:
         print(a[k],end=' ')
      else:
         print(a[k])

for i in range(1,n):
   v=a[i]
   j=i-1
   while(j>=0 and a[j]>v):
      a[j+1]=a[j]
      j-=1
   a[j+1]=v
   for k in range(0,n):
      if k!=n-1:
         print(a[k],end=' ')
      else:
         if i==(n-1):
            print(a[k],end='')
         else:
            print(a[k])

Submission status: WA: Presentation Error

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

for k in range(0,n):
      if k!=n-1:
         print(a[k],end=' ')
      else:
         print(a[k])

for i in range(1,n):
   v=a[i]
   j=i-1
   while(j>=0 and a[j]>v):
      a[j+1]=a[j]
      j-=1
   a[j+1]=v
   for k in range(0,n):
      if k!=n-1:
         print(a[k],end=' ')
      else:
         if i==n-1:
            print(a[k],end='')
         else:
            print(a[k])

Submission status: WA: Presentation Error

Solution code:
def insertionSort(A,N):
    for k in range(N):
        print(A[k], end=" ")
    print()
    for i in range(1, N):
        v = A[i]
        j = i-1
        while j >= 0 and A[j]>v:
            A[j+1] = A[j]
            j += -1
        A[j+1] = v
        for k in range(N):
            print(A[k], end=" ")
        print()
        
n = int(input())
nums = list(map(int, input().split()))
insertionSort(nums, n)

Submission status: WA: Presentation Error

Solution code:
def insertionSort(A,N):
    for k in range(N):
        print(A[k], end=" ")
    print()
    for i in range(1, N):
        v = A[i]
        j = i-1
        while j >= 0 and A[j]>v:
            A[j+1] = A[j]
            j += -1
        A[j+1] = v
        for k in range(N):
            print(A[k], end=" ")
        print()
n = int(input())
nums = list(map(int, input().split()))
insertionSort(nums, n)

Submission status: WA: Presentation Error

Solution code:
# 配列の要素数
num = int(input())

# 配列
array = list(map(int, input().split()))

def print_array():
    for i in range(num):
        print(array[i], end=' ')
    print()

# insertion sort
for i in range(num):
    insert = array[i]
    j = 0
    while array[j] < insert:
        j+=1
    for k in range(i, j, -1):
        array[k] = array[k - 1]
    array[j] = insert
    print_array()

Submission status: WA: Presentation Error

Solution code:
def insertionSort(a, n):
    trace(a)
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        trace(a)


def trace(a):
    output = ''
    for i in a:
        output += str(i) + ' '
    print(output)

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

Submission status: WA: Presentation Error

Solution code:
N = int(input())
A = list(map(int, input().split(" ")))
for a in A:
    print(a, end= " ")
print()
for i in range(1, N):
    v = A[i]
    j = i-1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    
    for a in A:
        print(a, end= " ")
    print()

Submission status: WA: Presentation Error

Solution code:
import sys

def insertionSort(x_list,y):
  for i in range(1, y):
    v = x_list[i]
    j = i - 1
    while j >= 0 and x_list[j] > v:
      x_list[j + 1] = x_list[j]
      j -= 1
    x_list[j+1] = v
    for k in range(0, y):
      print x_list[k],
    print " "

y = sys.stdin.readline()
y = int(y)

x = sys.stdin.readline()

x_list = x.split(" ")

for i in range(y):
  x_list[i] = int(x_list[i])

for k in range(0, y):
  print x_list[k],
print " "

insertionSort(x_list, y)

Submission status: WA: Presentation Error

Solution code:
import sys

def display(inp):
    for i in inp:
        print("%d " % i, end=" ")
    print("")

line = sys.stdin.readline()
size = int(line)
line = sys.stdin.readline()
inp = []
for i in line.split(" "):
    inp.append(int(i))

display(inp)

for i in range(1,size):
    if inp[i]!=size:
        check = inp.pop(i)
        for j in range(len(inp)):
            if check<inp[j]:
                inp.insert(j,check)
                break
    display(inp)

Submission status: WA: Presentation Error

Solution code:
def insertionSort(a, n):
    for i in range(1, n):
        show(a, n)
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
    else:
        show(a, n)

def show(a, n):
    for i in range(n):
        print "%d" % a[i],
    print ""

n = input()
a = map(int, raw_input().split())
insertionSort(a, n)

Submission status: WA: Presentation Error

Solution code:
def insertionSort(a, n):
    for i in range(1, n):
        show(a, n)
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
    else:
        show(a, n)

def show(a, n):
    for i in range(n):
        print "%d " % a[i],
        if i == n-1:
            print ""
        else:
            print " ",

n = input()
a = map(int, raw_input().split())
insertionSort(a, n)

Submission status: WA: Presentation Error

Solution code:
def insertionSort(a, n):
    for i in range(1, n):
        show(a, n)
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
    else:
        show(a, n)

def show(a, n):
    for i in range(n):
        print "%d" % a[i],
        if i == n-1:
            print ""
        else:
            print " ",

n = input()
a = map(int, raw_input().split())
insertionSort(a, n)

Submission status: WA: Presentation Error

Solution code:
q=input()
a=map(int,raw_input().split())
for i in range(q):
 k=a[i]
 j=i-1
 while j>=0 and a[j]>k:
  a[j+1]=a[j]
  j-=1
 a[j+1]=k
 text=""
 for I in a:
  text=text+' '+str(I)
 print(text)

Submission status: WA: Presentation Error

Solution code:
q=input()
a=map(int,raw_input().split())
for i in range(q):
 k=a[i]
 j=i-1
 while j>=0 and a[j]>k:
  a[j+1]=a[j]
  j-=1
 a[j+1]=k
 text=" "
 for I in a:
  text=text+' '+str(I)
 print(text)

Submission status: WA: Presentation Error

Solution code:
q=input()
a=map(int,raw_input().split())
for i in range(q):
 k=a[i]
 j=i-1
 while j>=0 and a[j]>k:
  a[j+1]=a[j]
  j-=1
 a[j+1]=k
 text=str()
 for I in a:
  text=text+' '+str(I)
 print(str(text))

Submission status: WA: Presentation Error

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

def insertin_sort(a, n):
    array_print(a)
    for i in range(1, n):
        v = a[i]
        j = i-1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        array_print(a)

def array_print(a):
    buf = ""
    for i in a:
        buf += str(i) + " "
    buf.rstrip()
    print buf


if __name__ == "__main__":
    n = int(raw_input())
    a = map(int, raw_input().split())
    insertin_sort(a, n)

Submission status: WA: Presentation Error

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

def insertin_sort(a, n):
    array_print(a)
    for i in range(1, n):
        v = a[i]
        j = i-1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        array_print(a)

def array_print(a):
    buf = ""
    for i in a:
        buf += str(i) + " "
#    buf.rstrip()
    print buf


if __name__ == "__main__":
    n = int(raw_input())
    a = map(int, raw_input().split())
    insertin_sort(a, n)

Submission status: WA: Presentation Error

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

def printElem(B):
    string = ""
    for elem in B:
        string += str(elem) + " "
    print(string)

printElem(A)

for i in range(1, n):
    key = A[i]
    j = i - 1

    while j >= 0 and A[j] > key:
        A[j+1] = A[j]
        j -= 1

    A[j+1] = key

    printElem(A)

Submission status: WA: Presentation Error

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

s= ''
for k in l:
	s+=' '+str(k)
print(s)

for m in range(n-1):
	j=m+1
	if(l[j-1]>l[j]):
		i=j
		while(not i==0):
			if(not(l[i-1]<l[i])):
				l[i-1],l[i]= l[i],l[i-1]
				i-=1
			else:
				break
	s= ''
	for k in l:
		s+=' '+str(k)
	print(s)

Submission status: WA: Presentation Error

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

s= ''
for k in l:
	s+=str(k)+' '
print(s)

for m in range(n-1):
	j=m+1
	if(l[j-1]>l[j]):
		i=j
		while(not i==0):
			if(not(l[i-1]<l[i])):
				l[i-1],l[i]= l[i],l[i-1]
				i-=1
			else:
				break
	s= ''
	for k in l:
		s+=str(k)+' '
	print(s)

Submission status: WA: Presentation Error

Solution code:
N=input()
A=map(int,raw_input().split())
for i in range(N-1):
	for k in range(N):
		print str(A[k])+" ",
	v=A[i+1]
	j=i
	while j>=0 and A[j] >v:
		A[j+1]=A[j]
		j=j-1
	A[j+1]=v
	print ""

for m in range(N):
		print str(A[m])+" ",

Submission status: WA: Presentation Error

Solution code:
N=input()
A=map(int,raw_input().split())
for i in range(N-1):
	for k in range(N):
		print str(A[k]),
	v=A[i+1]
	j=i
	while j>=0 and A[j] >v:
		A[j+1]=A[j]
		j=j-1
	A[j+1]=v
	print ""

for m in range(N):
		print str(A[m])+" ",

Submission status: WA: Presentation Error

Solution code:
N=input()
A=map(int,raw_input().split())
for i in range(N-1):
	for k in range(N):
		print str(A[k]),
	v=A[i+1]
	j=i
	while j>=0 and A[j] >v:
		A[j+1]=A[j]
		j=j-1
	A[j+1]=v
	print ""

for m in range(N):
		print str(A[m]),

Submission status: WA: Presentation Error

Solution code:
N=input()
A=map(int,raw_input().split())
for i in range(N-1):
	for k in range(N):
		print str(A[k]),
	v=A[i+1]
	j=i
	while j>=0 and A[j] >v:
		A[j+1]=A[j]
		j=j-1
	A[j+1]=v
	print ""

for m in range(N):
	print str(A[m]),

Submission status: WA: Presentation Error

Solution code:
N=input()
A=map(int,raw_input().split())
for i in range(N-1):
	for k in range(N):
		print str(A[k]),
	v=A[i+1]
	j=i
	while j>=0 and A[j] >v:
		A[j+1]=A[j]
		j=j-1
	A[j+1]=v
	print ""

for m in range(N):
	print str(A[m]),
print ""

Submission status: WA: Presentation Error

Solution code:
N=input()
A=map(int,raw_input().split())
for i in range(N-1):
	for k in range(N-1):
		print A[k],
	print A[N-1]
	v=A[i+1]
	j=i
	while j>=0 and A[j] >v:
		A[j+1]=A[j]
		j=j-1
	A[j+1]=v
	print ""

for m in range(N-1):
	print str(A[m]),
print A[N-1]

Submission status: WA: Presentation Error

Solution code:
def insertionSort(A):
    for k in range(len(A)):
            print A[k],
    print ""
    for i in range(1, len(A)):
        temp = A[i]
        j = i-1
        while j >= 0 and A[j] > temp:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = temp
        for k in range(len(A)):
            print A[k],
        print ""

N = int(raw_input())
A = map(int, raw_input().split())

insertionSort(A)

Submission status: WA: Presentation Error

Solution code:
N = int(input())
#print(N)
card = list(map(int, input().split()))
#print(card)

for i in range(N):
    v = card[i]
    j = i - 1
    while j >= 0 and card[j] > v:
        card[j+1] = card[j]
        j = j -1
    card[j+1] = v
    #print(card)
    card_str = ""
    for k in range(N):
      card_str += str(card[k])
    print(card_str)

Submission status: WA: Presentation Error

Solution code:
N = int(input())
#print(N)
card = list(map(int, input().split()))
#print(card)

for i in range(N):
    v = card[i]
    j = i - 1
    while j >= 0 and card[j] > v:
        card[j+1] = card[j]
        j = j -1
    card[j+1] = v
    #print(card)
    card_str = ""
    for k in range(N):
      card_str += " " + str(card[k])
    print(card_str)

Submission status: WA: Presentation Error

Solution code:
N = int(input())
#print(N)
card = list(map(int, input().split()))
#print(card)

for i in range(N):
    v = card[i]
    j = i - 1
    while j >= 0 and card[j] > v:
        card[j+1] = card[j]
        j = j -1
    card[j+1] = v
    #print(card)
    card_str = ""
    for k in range(N):
      card_str = card_str +  " " + str(card[k])
    print(card_str)

Submission status: WA: Presentation Error

Solution code:
#input number
n = raw_input()

if n < 1 and n > 100:
	exit()

# input elements
l = raw_input()

elements = l.split()

o = ''
for e in elements:
	o += str(e) + ' '
print o

for i in range(1, int(n)):
	key = elements[i]
	j = i - 1
	while j >= 0 and elements[j] > key:
		elements[j + 1] = elements[j]
		j -= 1
	elements[j + 1] = key
	# output
	o = ''
	for e in elements:
		o += str(e) + ' '
	print o

Submission status: WA: Presentation Error

Solution code:
'Insertion Sort'


def insertion_sort(target_list):
    '????????????????????????????????\???????????§??????????????????????????¨?????????'
    sorted_list = [target_list.pop(0)]
    for target in target_list[:]:
        print(' '.join(str(s)for s in sorted_list + target_list))
        for i, num in enumerate(sorted_list):
            if num > target:
                sorted_list[i:i] = [target]
                break
        else:
            sorted_list.append(target)
        target_list.pop(0)
    print(' '.join(str(s)for s in sorted_list + target_list), end='')

N = int(input())
A = [int(s) for s in input().split()]
insertion_sort(A)

Submission status: WA: Presentation Error

Solution code:
def insertionSort(lis,leng):
    for i in range(leng):
        v = lis[i]
        j = i - 1
        while j >= 0 and lis[j] > v:
            lis[j+1] = lis[j]
            j = j-1
        lis[j+1]=v
        print("".join(lis))

        
if __name__ == "__main__":
    leng=int(input())
    lis=input().split()
    insertionSort(lis,leng)

Submission status: WA: Presentation Error

Solution code:
def insertion_sort(array, element_number):
    for i in range(0, element_number):
        v = array[i]
        j = i - 1

        while(j>=0 and array[j] > v):
            array[j+1] = array[j]
            j = j - 1

        array[j+1] = v

        for k in range(0, element_number):
            if k < element_number:
                print(array[k] + ' ', end='')
            else:
                print(array[k], end='')

        if i < element_number-1:
            print('\n', end='')

def test():
    element_number = int(input())
    input_array = input().split()

    insertion_sort(input_array, element_number)

if __name__ == '__main__':
    test()

Submission status: WA: Presentation Error

Solution code:
def insertion_sort(array, element_number):
    for i in range(0, element_number):
        v = array[i]
        j = i - 1

        while(j>=0 and array[j] > v):
            array[j+1] = array[j]
            j = j - 1

        array[j+1] = v

        for k in range(0, element_number):
            if k < element_number-1:
                print(array[k] + ' ', end='')
            else:
                print(array[k], end='')

        if i < element_number-1:
            print('\n', end='')

def test():
    element_number = int(input())
    input_array = input().split()

    insertion_sort(input_array, element_number)

if __name__ == '__main__':
    test()

Submission status: WA: Presentation Error

Solution code:
import sys


def print_arr(arr):
    ln = ''
    for v in arr:
        ln += str(v) + ' '

    ln.strip()
    print(ln)

def insertion_sort(arr):
    for i in range(1, len(arr)):
        print_arr(arr)
        v = arr[i]
        j = i-1
        while j >= 0 and arr[j] > v:
            arr[j+1] = arr[j]
            j -= 1
        arr[j+1] = v

    print_arr(arr)

input0 = sys.stdin.readline()
input_sample = sys.stdin.readline()
# input_sample = "5 2 4 6 1 3"
input = input_sample.split(" ")
input = [int(i) for i in input]
insertion_sort(input)

Submission status: WA: Presentation Error

Solution code:
#ALDS1_1-A
def insertionSort(A,N):
    for i in range(N-1):
        v=A[i+1]
        j=i
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j-=1
        A[j+1]=v
        stri = ""
        for i in range(N):
            stri+=str(A[i])+" "
        print(stri)
N=int(input())
A=[int(x) for x in input().split()]
stri = ""
for i in range(N):
    stri+=str(A[i])+" "
print(stri)
insertionSort(A,N)

Submission status: WA: Presentation Error

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

for k in A:
    print(str(k) + " ", end="")
print()

for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j+1] = v
    for k in A:
        print(str(k) + " ", end="")
    print()

Submission status: WA: Presentation Error

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

def print_list(A):
    for a in A[:-1]:
        print (a, end="")
    print(A[-1])

def InsertionSort(A, N):
    print_list(A)
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print_list(A)

InsertionSort(A, N)

Submission status: WA: Presentation Error

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
B=""
for k in range(N):
    B+=str(A[k])+" "
print(B)
for i in range(1,N):
    j=i-1
    v=A[i]
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j-=1
    A[j+1]=v
    B=""
    for k in range(N):
        B+=str(A[k])+" "
    print(B)

Submission status: WA: Presentation Error

Solution code:
# your code goes here
N=int(input())
A=[int(i) for i in input().split()]
for i in range(1,N):
    B=""
    for k in range(N):
        B+=str(A[k])+" "
    print(B)
    j=i-1
    v=A[i]
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j-=1
    A[j+1]=v
B=""
for k in range(N-1):
    B+=str(A[k])+" "
B+=str(A[N-1])
print(B)

Submission status: WA: Presentation Error

Solution code:
import random,time

'''
#start = time.time()
list = [i for i in range(1000000)]
#result = time.time() - start
#print(result)

random.shuffle(list)
list2 = list[:]

#print(list,list2)


start = time.time()
list2.sort(key=int)
result = time.time() - start
print(result)
#print(list2)


'''
s = input()
list = list(map(int,input().split()))


#print(list)
for row in list:
    print(row,end=' ')
print()
start = time.time()
i = 0
for count in range(len(list)-1):

#   Judge: now > next
    if list[i] > list[i+1]:

#       Change: now > next
        ins_num = list[i+1]
        list[i+1] = list[i]
        list[i]   = ins_num

        j = i - 1

        while j >= 0:
            if list[j] > ins_num:
                list[j+1] = list[j]
                list[j]   = ins_num

            j -= 1
        for row in list:
            print(row,end=' ')
    else:
        for row in list:
            print(row,end=' ')        
    
    print()
    i += 1

result = time.time() - start
#print(result)
#print(list)

Submission status: WA: Presentation Error

Solution code:
n = int(input())

array = input().split()

intarr = [int(x) for x in array]
for x in intarr:
    print(x, end=' ')
    if x == intarr[-1]:
        print()
    

for c in range(1,n):
    v = intarr[c]
    j = c-1
    while j>=0 and intarr[j]>v:
        intarr[j+1] = intarr[j]
        j -= 1
    intarr[j+1] = v
    for x in intarr:
        print(x,end=' ')
        if x == intarr[-1]:
            print()

Submission status: WA: Presentation Error

Solution code:
if __name__ == '__main__':
    N = (int)(input())
    A = list(map(int,input().split()))
    print(' '.join(map(str,A)))

    for i in range(1,N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j = j -1
        A[j+1] = v
        if i == N - 1:
            print(' '.join(map(str,A)),end = '')
        else:
            print(' '.join(map(str,A)))

Submission status: WA: Presentation Error

Solution code:
def inserts(N):
    for n in N:
        print(str(n)+" ", end='')
    print("")
    for i in range(1,len(N)):
        # ?????????????´??????????????????£????????¨?????????
        v = N[i]
        j = i - 1
        while j >= 0 and N[j] > v:
            N[j + 1] = N[j]
            j -= 1
        N[j + 1] = v
        for n in N:
            print(str(n)+" ", end='')
        print("")


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

inserts(numbers)

Submission status: WA: Presentation Error

Solution code:
def inserts(N):
    for n in N:
        print(' '+str(n), end='')
    print("")
    for i in range(1,len(N)):
        # ?????????????´??????????????????£????????¨?????????
        v = N[i]
        j = i - 1
        while j >= 0 and N[j] > v:
            N[j + 1] = N[j]
            j -= 1
        N[j + 1] = v
        for n in N:
            print(' '+str(n), end='')
        print("")


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

inserts(numbers)

Submission status: WA: Presentation Error

Solution code:
def inserts(N):
    for n in N:
        i = 1
        print(n, end='')
        if i > 0:
            print(' ', end='')
    print("")
    for i in range(1,len(N)):
        # ?????????????´??????????????????£????????¨?????????
        v = N[i]
        j = i - 1
        while j >= 0 and N[j] > v:
            N[j + 1] = N[j]
            j -= 1
        N[j + 1] = v
        for n in N:
            i = 1
            print(n, end='')
            if i > 0:
                print(' ', end='')
        print("")

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

inserts(numbers)

Submission status: WA: Presentation Error

Solution code:
def trace(A,input_num):
    i = 0
    if i != input_num - 1:   
        for i in range(input_num):
            print(A[i],end = " ")
    else:
        print(A[i])
        
    print("\n")

def insertionSort(A,input_num):
    for i in range(input_num):
        v = A[i]
        j = i - 1
        while(j >= 0 and A[j] > v):
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        trace(A,input_num)
        
        
input_num = int(input())
A = list(map(int, input().split()))

insertionSort(A,input_num)

Submission status: WA: Presentation Error

Solution code:
def trace(A,input_num):
    i = 0
    if i != input_num - 1:
        for i in range(input_num):
            print(A[i],end = " ")
    
    else:
        print(A[i])

def insertionSort(A,input_num):
    for i in range(input_num):
        v = A[i]
        j = i - 1
        while(j >= 0 and A[j] > v):
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        trace(A,input_num)
        if i != input_num:
            print("\n")
        
        
input_num = int(input())
A = list(map(int, input().split()))

insertionSort(A,input_num)

Submission status: WA: Presentation Error

Solution code:
def trace(A,input_num):
    i = 0
    for i in range(input_num):
        if i != input_num - 1:
            print(A[i],end = " ")
        else:
            print(A[i])

def insertionSort(A,input_num):
    for i in range(input_num):
        v = A[i]
        j = i - 1
        while(j >= 0 and A[j] > v):
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        trace(A,input_num)
        if i != input_num-1:
            print("\n")
        
        
input_num = int(input())
A = list(map(int, input().split()))

insertionSort(A,input_num)

Submission status: WA: Presentation Error

Solution code:
def trace(A,input_num):
    i = 0
    for i in range(input_num):
        if i != input_num - 1:
            print(A[i],end = " ")
        else:
            print(A[i])

def insertionSort(A,input_num):
    for i in range(input_num):
        v = A[i]
        j = i - 1
        while(j >= 0 and A[j] > v):
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        trace(A,input_num)
        if i != input_num-1:
            print(" ")
        
        
input_num = int(input())
A = list(map(int, input().split()))

insertionSort(A,input_num)

Submission status: WA: Presentation Error

Solution code:
import sys

input_len = int(input())
l = input().split()
sort_line = [0 for i in range(input_len)]
for i in range(input_len):
	sort_line[i] = int(l[i])
	

for k in range(input_len):
	sys.stdout.write(str(sort_line[k]) + " ")
print()

for i in range(1, input_len):
	v = sort_line[i]
	j = i - 1
	while (j >= 0 and v < sort_line[j]):
		sort_line[j+1] = sort_line[j]
		j -= 1
	sort_line[j + 1] = v

	for k in range(input_len):
		sys.stdout.write(str(sort_line[k]) + " ")
	print()

Submission status: WA: Presentation Error

Solution code:
import sys

input_len = int(input())
l = input().split()
sort_line = [0 for i in range(input_len)]
for i in range(input_len):
	sort_line[i] = int(l[i])

for k in range(input_len):
	sys.stdout.write(str(sort_line[k]) + " ")
print()

for i in range(1, input_len):
	v = sort_line[i]
	j = i - 1
	while (j >= 0 and v < sort_line[j]):
		sort_line[j+1] = sort_line[j]
		j -= 1
	sort_line[j + 1] = v

	for k in range(input_len):
		sys.stdout.write(str(sort_line[k]) + " ")
	print()

Submission status: WA: Presentation Error

Solution code:
def insertionsort(A, n):
    for i in range(1, n):
        prt(A)
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
    prt(A)

def prt(A):
    for i in A:
        print(i, end=" ")
    print()

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

Submission status: WA: Presentation Error

Solution code:
#16D8101014F 久留米 竜之介 Utyan0604 python3
def insertionsort(n,A):
	for i in range(n):
		t=A[i]
		j=i-1
		while j>=0 and A[j] > t:
			A[j+1]=A[j]
			j-=1
			A[j+1]=t
		for k in range(n):
				print(A[k],end=" ")
		print()
			
n=int(input())
A=list(map(int, input().split()))


insertionsort(n,A)

Submission status: WA: Presentation Error

Solution code:
import copy


def parse_stdin(input_lines: int):
    data_list = []
    for i in range(input_lines):
        data_list.append(input().rstrip().split())
    return data_list


def insertion_sort_with_print(values):
    print_now_state(values)
    for i, value in enumerate(values[1:]):
        i += 1
        j = i - 1
        while j >= 0 and values[j] > value:
            values[j + 1] = copy.copy(values[j])
            j -= 1
        values[j + 1] = copy.copy(value)
        print_now_state(values)


def print_now_state(values):
    for val_print in values:
        print("{} ".format(val_print), end='')
    print()


def main():
    input()
    input_lists = parse_stdin(1)
    values = list(map(int, input_lists[0]))
    insertion_sort_with_print(values)


if __name__ == '__main__':
    main()

Submission status: WA: Presentation Error

Solution code:
x = int(input())
li = list(map(int, input().split()))

for i in range(x):
    v = li[i]
    j = i - 1
    while j >= 0 and li[j] > v:
        li[j+1] = li[j]
        j -= 1
    li[j+1] = v
    for j in range(x):
        print(li[j], end=" ")
        if j == x-1:
            print(end="\n")

Submission status: WA: Presentation Error

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

for i in range(x):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    for j in range(x):
        print(A[j], end=" ")
        if j == x-1:
            print(end="\n")

Submission status: WA: Presentation Error

Solution code:
a=[]
n=int(input())
a=input().strip().split(' ')
for i in range(n):
	v=a[i]
	j=i-1
	while j>=0 and a[j]>v:
		a[j+1]=a[j]
		j=j-1
	a[j+1]=v
	for k in range(len(a)):
		print(a[k]," ",end="")
	print("\n")

Submission status: WA: Presentation Error

Solution code:
a=[]
n=int(input())
a=input().strip().split(' ')
for i in range(n):
	v=a[i]
	j=i-1
	while j>=0 and a[j]>v:
		a[j+1]=a[j]
		j=j-1
	a[j+1]=v
	for k in range(len(a)):
		print(a[k],end=" ")
	print()

Submission status: WA: Presentation Error

Solution code:
a=[]
n=int(input())
a=input().strip().split(' ')
for i in range(n):
	v=a[i]
	j=i-1
	while j>=0 and a[j]>v:
		a[j+1]=a[j]
		j=j-1
	a[j+1]=v
	for k in range(len(a)):
		print(a[k],end=" ")
	if i==n-1:
		break
	else:
		print()

Submission status: WA: Presentation Error

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

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

for k in range(N):
    print('{0} '.format(A[k]), end='')
print()

for i in range(1, N):
    v = A[i]
    j = i - 1
    while (j >= 0) and (A[j] > v):
        A[j + 1], A[j] = A[j], v
        j -= 1

    for k in range(N):
        print('{0} '.format(A[k]), end='')
    print()

Submission status: WA: Presentation Error

Solution code:
def insertion_sort(a, n):
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j + 1] = a[j]
            j -= 1
        a[j + 1] = v
        print_list_split_whitespace(a)

def print_list_split_whitespace(a):
    for x in a:
        print(x, end=' ')
    print()


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

print_list_split_whitespace(a)
insertion_sort(a, n)

Submission status: WA: Presentation Error

Solution code:
# coding = utf-8



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


for k in A:
    print(k, end=" ")
print()

for i in range(1, N):
    v = A[i]
    j = i-1
    while(j >= 0 and A[j] > v):
        A[j+1] = A[j]
        j = j-1
        A[j+1] = v

    for k in A:
        print(k, end=" ")
    # if i != N-1:
    print()