s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s894348775
p02259
u630546605
1497163778
Python
Python
py
Runtime Error
0
0
464
# # coding: utf-8 def bubbleSort(arr, n): flag = True swap_num = 0 while flag: flag = False for j in xrange(n-1, 0, -1): if arr[j] < arr[j-1]: arr[j], arr[j-1] = arr[j-1], arr[j] swap_num += 1 flag = True pass return swap_num n = int(raw_input()) arr = map(int, raw_input().split()) num = bubbleSort(arr, n) print " ".join(map(str, test_arr)) print num
s006706587
p02259
u609303956
1497857442
Python
Python
py
Runtime Error
0
0
303
N = int(input()) text = input() A = text.split() A = list(map(int, A)) trials = 0 for i in range(0, N-1): for j in range(N-1, i, -1): if A[j] < A[j-1]: A[j], A[j-1] = A[j-1], A[j] trials += 1 print(trials) for i in range(len(A)): print(A[i], end=" ") print("")
s659044496
p02259
u609303956
1497857628
Python
Python
py
Runtime Error
0
0
635
N = int(input("Enter the length of the array: ")) text = input("Enter the array: ") A = text.split() A = list(map(int, A)) #if N != len(A): # print("The length of the array is incorrect!! ") # print("N=" + str(N) + ", the actual length of A = " + str(len(A))) #else: # print("The length of the array is: " + str(len(A))) # Bubble Sort trials = 0 for i in range(0, N-1): for j in range(N-1, i, -1): if A[j] < A[j-1]: A[j], A[j-1] = A[j-1], A[j] trials += 1 # print the number of trials print(trials) # print bubble-sorted array for i in range(len(A)): print(A[i], end=" ") print("")
s617708065
p02259
u747635679
1498195657
Python
Python3
py
Runtime Error
0
0
282
n = int(input()) a = [int(x) for x in input().split()] c = 0 for i in range(n): for j in range(i + 1, n): if a[j - 1] > a[j]: tmp = a[j - 1] a[j - 1] = a[j] a[j] = tmp c += 1 print(" ".join([str(x) for x in a]) print(c)
s114838873
p02259
u735204496
1498977714
Python
Python
py
Runtime Error
0
0
576
import sys def swap(a, i, j): tmp = a[j] a[j] = a[i] a[i] = tmp return a def list_to_string(a): s = "" for n in a: s += str(n) + " " return s.strip() num = int(sys.stdin.readline().strip()) array = map(lambda x: int(x), sys.stdin.readline().strip().split(" ")) flag = True swap_num = 0 while flag: flag = False for i in range(1, len(array)).reverse(): if array[i] < array[i - 1]: swap(a, i, i-1) flag = True swap_num += 1 print list_to_string(array) print str(swap_num)
s117924293
p02259
u735204496
1498977762
Python
Python
py
Runtime Error
0
0
576
import sys def swap(a, i, j): tmp = a[j] a[j] = a[i] a[i] = tmp return a def list_to_string(a): s = "" for n in a: s += str(n) + " " return s.strip() num = int(sys.stdin.readline().strip()) array = map(lambda x: int(x), sys.stdin.readline().strip().split(" ")) flag = True swap_num = 0 while flag: flag = False for i in range(1, len(array)).reverse(): if array[i] < array[i - 1]: swap(a, i, i-1) flag = True swap_num += 1 print list_to_string(array) print str(swap_num)
s095663599
p02259
u735204496
1498977969
Python
Python
py
Runtime Error
10
6456
576
import sys def swap(a, i, j): tmp = a[j] a[j] = a[i] a[i] = tmp return a def list_to_string(a): s = "" for n in a: s += str(n) + " " return s.strip() num = int(sys.stdin.readline().strip()) array = map(lambda x: int(x), sys.stdin.readline().strip().split(" ")) flag = True swap_num = 0 while flag: flag = False for i in reversed(range(1, len(array))): if array[i] < array[i - 1]: swap(a, i, i-1) flag = True swap_num += 1 print list_to_string(array) print str(swap_num)
s485532806
p02259
u821624310
1503610242
Python
Python3
py
Runtime Error
0
0
305
import output N = int(input()) A = [int(n) for n in input().split()] flg = 1 cnt = 0 while flg: flg = 0 for i in range(N-1, 0, -1): if A[i] < A[i-1]: t = A[i] A[i] = A[i-1] A[i-1] = t flg = 1 cnt += 1 output.print_1(A) print(cnt)
s974917569
p02259
u146816547
1504524097
Python
Python
py
Runtime Error
0
0
395
def bubbleSort(A, N): c = 0 flag = 1 # ????????ยฃ??\????ยด?????????ยจ?????? while flag: flag = 0 for j in range(N-1, 0, -1): if A[j] < A[j-1]: A[j], A[j-1] = A[j-1], A[j] c += 1 flag = 1 print " ".join(map(str, A)) print c N = int(raw_input()) L = map(int, raw_input().split()) bubbleSort(L, N)
s801991488
p02259
u480053997
1508374895
Python
Python
py
Runtime Error
0
0
341
def bubblesort(N, A): c, flag = 0, 1 while flag: flag = False for j in range(N-1, 0, -1): if A[j] < A[j-1]: A[j], A[j-1] = A[j- 1], A[j] c += 1 flag = True return (A, c) A, c = bubblesort(int(input()), list(map(int, input().split()))) print(A) print(c)
s368791562
p02259
u514487486
1509157578
Python
Python3
py
Runtime Error
30
7612
419
def bubbleSort(A, N): flag = 1 count = 0 while flag == 1: flag = 0 for i in range(1, N)[::-1]: if A[j] < A[j - 1]: tmp = A[j] A[j] = A[j - 1] A[j - 1] = tmp flag = 1 count += 1 print(" ".join(map(str, A))) print(count) n = int(input()) A = list(map(int, input().split())) bubbleSort(A, n)
s955917687
p02259
u626266743
1510021084
Python
Python3
py
Runtime Error
0
0
316
N = int(input()) A = list(map(int, input().split())) count = 0 Flag = True while Flag: Fag = Flase for i in range(N-1, 1): if(A[i] < A[i-1]): temp = A[i-1] A[i-1] = A[i] A[i] = temp Flag = True count += 1 print(*A) print(count)
s376552892
p02259
u626266743
1510021100
Python
Python3
py
Runtime Error
0
0
317
N = int(input()) A = list(map(int, input().split())) count = 0 Flag = True while Flag: Flag = Flase for i in range(N-1, 1): if(A[i] < A[i-1]): temp = A[i-1] A[i-1] = A[i] A[i] = temp Flag = True count += 1 print(*A) print(count)
s883418352
p02259
u626266743
1510021256
Python
Python3
py
Runtime Error
0
0
281
N = int(input()) A = list(map(int, input().split())) count = 0 flag = True while Flag: flag = False for i in range(N-1, 1): if(A[i] < A[i-1]): A[i], A[i-1] = A[i-1], A[i] flag = True count += 1 print(*A) print(count)
s493593656
p02259
u424041287
1512119774
Python
Python3
py
Runtime Error
30
5604
423
def bubbleSort(A, N): s = 0 flag = 0 while flag == 0: flag = 1 for j in range(N - 1, 0, -1): if A[j] < A[j - 1]: A[j], A[j - 1] = A[j - 1], A[j] flag = 0 t += 1 t = str(A[0]) for i in range(1,N): t = t + " " + str(A[i]) print(t) print(s) n = int(input()) a = [int(i) for i in input().split()] bubbleSort(a, n)
s081075244
p02259
u203261375
1515109495
Python
Python3
py
Runtime Error
0
0
361
def bubble_sort(A): swap_cnt = 0 for i in range(len(A)): for j in range(len(A), i + 1, -1): if A[j] < A[j - 1]: A[j], A[j - 1] = A[j - 1], A[j] swap_cnt += 1 return A, swap_cnt n = int(input()) A = list(map(int, input().split())) A, swap_cnt = bubble_sort(A) print(' '.join(A)) print(swap_cnt)
s629505989
p02259
u203261375
1515109701
Python
Python3
py
Runtime Error
20
5592
371
def bubble_sort(A): swap_cnt = 0 for i in range(len(A)): for j in range(len(A), i + 1, -1): if A[j] < A[j - 1]: A[j], A[j - 1] = A[j - 1], A[j] swap_cnt += 1 return A, swap_cnt n = int(input()) A = list(map(int, input().split())) A, swap_cnt = bubble_sort(A) print(' '.join(map(str, A))) print(swap_cnt)
s710115470
p02259
u152639966
1516020091
Python
Python3
py
Runtime Error
0
0
216
n=int(input()) s=input().split(' ') flag=1 m=0 while flag: flag=0 for j in range(1,n): j=n-j if s[j]<s[j-1]: a=s[j] s[j]=s[j-1] s[j-1]=a m+=1 flag=1 print(' '.join(s)) print(m)
s736611088
p02259
u152639966
1516020136
Python
Python3
py
Runtime Error
0
0
216
n=int(input()) s=input().split(' ') flag=1 m=0 while flag: flag=0 for j in range(1,n): j=n-j if s[j]<s[j-1]: a=s[j] s[j]=s[j-1] s[j-1]=a m+=1 flag=1 print(' '.join(s)) print(m)
s960924100
p02259
u152639966
1516116039
Python
Python3
py
Runtime Error
0
0
477
n=int(input()) s=input().split(' ') flag=1 m=0 while flag: ใ€€ใ€€ใ€€ใ€€flag=0 ใ€€ใ€€ใ€€ใ€€for j in range(1,n): ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€j=n-j ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€if s[j]<s[j-1]: ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€a=s[j] ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€s[j]=s[j-1] ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€s[j-1]=a ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€m+=1 ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€flag=1 ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€print(j) print(' '.join(s)) print(m)
s946866909
p02259
u152639966
1516116195
Python
Python3
py
Runtime Error
0
0
477
n=int(input()) s=input().split(' ') flag=1 m=0 while flag: ใ€€ใ€€ใ€€ใ€€flag=0 ใ€€ใ€€ใ€€ใ€€for j in range(1,n): ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€j=n-j ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€if s[j]<s[j-1]: ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€a=s[j] ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€s[j]=s[j-1] ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€s[j-1]=a ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€m+=1 ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€flag=1 ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€print(j) print(' '.join(s)) print(m)
s717873829
p02259
u152639966
1516116313
Python
Python3
py
Runtime Error
0
0
432
n=int(input()) s=input().split(' ') flag=1 m=0 while flag: ใ€€ใ€€ใ€€ใ€€flag=0 ใ€€ใ€€ใ€€ใ€€for j in range(1,n): ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€j=n-j ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€if s[j]<s[j-1]: ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€a=s[j] ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€s[j]=s[j-1] ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€s[j-1]=a ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€m+=1 ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€flag=1 print(' '.join(s)) print(m)
s356316971
p02259
u464859367
1522131999
Python
Python3
py
Runtime Error
20
5600
377
n = int(input()) *array, = [int(input()) for i in range(n)] def bubble_sort(a): c = 0 flag = 1 i = 0 while flag: flag = 0 for j in range(n-1, i, -1): if a[j] < a[j-1]: a[j], a[j-1] = a[j-1], a[j] c += 1 flag = 1 i += 1 print(*a) print(c) bubble_sort(array)
s957391544
p02259
u405478089
1524796921
Python
Python
py
Runtime Error
0
0
408
def BS(A, N): A = list(map(int, A.split())) flag = 1 count = 0 while flag: flag = 0 for j in range(N-1, 0, -1): if A[j] < A[j-1]: unk = A[j] A[j] = A[j-1] A[j-1] = unk flag = 1 count = count +1 print(" ".join(map(str,A))) print(count) N = int(input()) A = input() BS(A, N)
s322188306
p02259
u226008611
1525952840
Python
Python3
py
Runtime Error
0
0
1420
use std::io; use std::str::FromStr; fn read_line() -> String { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); s } macro_rules! from_line { ($($a:ident : $t:ty),+) => { $(let $a: $t;)+ { let _line = read_line(); let mut _it = _line.trim().split_whitespace(); $($a = _it.next().unwrap().parse().unwrap();)+ assert!(_it.next().is_none()); } }; } fn main() { from_line!(n: u64); let stdin = io::stdin(); let mut buf = String::new(); stdin.read_line(&mut buf).ok(); let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap()); let mut v: Vec<i64> = buf.split_whitespace() .map(|n| i64::from_str(n).unwrap()) .collect(); let mut flag = true; let mut count = 0; while flag { flag = false; for j in 1..n { if v[j as usize] < v[(j - 1) as usize] { let tmp = v[(j - 1) as usize]; v[(j - 1) as usize] = v[j as usize]; v[j as usize] = tmp; count += 1; flag = true; } } } while !v.is_empty() { if v.len() == 1 { print!("{}", v.pop().unwrap()); } else { print!("{} ", v.pop().unwrap()); } } println!(""); println!("{:?}", count); }
s568826616
p02259
u865220118
1526620783
Python
Python
py
Runtime Error
0
0
685
# ใƒชใ‚นใƒˆใฎๅฎฃ่จ€ A = [] # ๅ…ฅๅŠ›ใฎๆœ€ๅˆใฎ่กŒใซใ€ๆ•ฐๅˆ—ใฎ้•ทใ•ใ‚’่กจใ™ๆ•ดๆ•ฐ N ใŒไธŽใˆใ‚‰ใ‚Œใพใ™ใ€‚ # 2 ่กŒ็›ฎใซใ€N ๅ€‹ใฎๆ•ดๆ•ฐใŒ็ฉบ็™ฝๅŒบๅˆ‡ใ‚ŠใงไธŽใˆใ‚‰ใ‚Œใพใ™ใ€‚ LENGTH =int(input()) A = input().split() # ๅค‰ๆ•ฐ N = 0 M = LENGTH - 1 CHANGE = 0 # BubbleSort(A) # for i = 0 to A.length-1 while N <= LENGTH -1 : M = LENGTH - 1 print ('N=',N) # for j = A.length-1 downto i+1 while M >= N + 1: print ('-M=',M) # if A[j] < A[j-1] if A[M] < A[M-1] : tmp = A[M-1] A[M-1] = A[M] A[M] = tmp CHANGE += 1 M -= 1 N += 1 print(" ".join(map(str,A))) print (CHANGE)
s786554286
p02259
u865220118
1526620840
Python
Python
py
Runtime Error
0
0
686
# ใƒชใ‚นใƒˆใฎๅฎฃ่จ€ A = [] # ๅ…ฅๅŠ›ใฎๆœ€ๅˆใฎ่กŒใซใ€ๆ•ฐๅˆ—ใฎ้•ทใ•ใ‚’่กจใ™ๆ•ดๆ•ฐ N ใŒไธŽใˆใ‚‰ใ‚Œใพใ™ใ€‚ # 2 ่กŒ็›ฎใซใ€N ๅ€‹ใฎๆ•ดๆ•ฐใŒ็ฉบ็™ฝๅŒบๅˆ‡ใ‚ŠใงไธŽใˆใ‚‰ใ‚Œใพใ™ใ€‚ LENGTH =int(input()) A = input().split() # ๅค‰ๆ•ฐ N = 0 M = LENGTH - 1 CHANGE = 0 # BubbleSort(A) # for i = 0 to A.length-1 while N <= LENGTH -1 : M = LENGTH - 1 # print ('N=',N) # for j = A.length-1 downto i+1 while M >= N + 1: # print ('-M=',M) # if A[j] < A[j-1] if A[M] < A[M-1] : tmp = A[M-1] A[M-1] = A[M] A[M] = tmp CHANGE += 1 M -= 1 N += 1 print(" ".join(map(str,A))) print (CHANGE)
s278183319
p02259
u865220118
1526620894
Python
Python
py
Runtime Error
0
0
686
# ใƒชใ‚นใƒˆใฎๅฎฃ่จ€ A = [] # ๅ…ฅๅŠ›ใฎๆœ€ๅˆใฎ่กŒใซใ€ๆ•ฐๅˆ—ใฎ้•ทใ•ใ‚’่กจใ™ๆ•ดๆ•ฐ N ใŒไธŽใˆใ‚‰ใ‚Œใพใ™ใ€‚ # 2 ่กŒ็›ฎใซใ€N ๅ€‹ใฎๆ•ดๆ•ฐใŒ็ฉบ็™ฝๅŒบๅˆ‡ใ‚ŠใงไธŽใˆใ‚‰ใ‚Œใพใ™ใ€‚ LENGTH =int(input()) A = input().split() # ๅค‰ๆ•ฐ N = 0 M = LENGTH - 1 CHANGE = 0 # BubbleSort(A) # for i = 0 to A.length-1 while N <= LENGTH -1 : M = LENGTH - 1 # print ('N=',N) # for j = A.length-1 downto i+1 while M >= N + 1: # print ('-M=',M) # if A[j] < A[j-1] if A[M] < A[M-1] : tmp = A[M-1] A[M-1] = A[M] A[M] = tmp CHANGE += 1 M -= 1 N += 1 print(" ".join(map(str,A))) print (CHANGE)
s750543507
p02259
u865220118
1526621066
Python
Python
py
Runtime Error
0
0
687
# ใƒชใ‚นใƒˆใฎๅฎฃ่จ€ A = [] # ๅ…ฅๅŠ›ใฎๆœ€ๅˆใฎ่กŒใซใ€ๆ•ฐๅˆ—ใฎ้•ทใ•ใ‚’่กจใ™ๆ•ดๆ•ฐ N ใŒไธŽใˆใ‚‰ใ‚Œใพใ™ใ€‚ # 2 ่กŒ็›ฎใซใ€N ๅ€‹ใฎๆ•ดๆ•ฐใŒ็ฉบ็™ฝๅŒบๅˆ‡ใ‚ŠใงไธŽใˆใ‚‰ใ‚Œใพใ™ใ€‚ LENGTH =int(input()) A = input().split() # ๅค‰ๆ•ฐ N = 0 M = LENGTH - 1 CHANGE = 0 # BubbleSort(A) # for i = 0 to A.length-1 while N <= LENGTH -1 : M = LENGTH - 1 # print ('N=',N) # for j = A.length-1 downto i+1 while M >= N + 1: # print ('-M=',M) # if A[j] < A[j-1] if A[M] < A[M-1] : tmp = A[M-1] A[M-1] = A[M] A[M] = tmp CHANGE += 1 M -= 1 N += 1 print(" ".join(map(str,A))) print (CHANGE)
s534664733
p02259
u405478089
1527214046
Python
Python
py
Runtime Error
0
0
408
def BS(A, N): A = list(map(int, A.split())) flag = 1 count = 0 while flag: flag = 0 for j in range(N-1, 0, -1): if A[j] < A[j-1]: unk = A[j] A[j] = A[j-1] A[j-1] = unk flag = 1 count = count +1 print(" ".join(map(str,A))) print(count) N = int(input()) A = input() BS(A, N)
s839635276
p02259
u405478089
1527214166
Python
Python
py
Runtime Error
0
0
564
def bubbleSort(A, N): # N ๅ€‹ใฎ่ฆ็ด ใ‚’ๅซใ‚€ 0-ใ‚ชใƒชใ‚ธใƒณใฎ้…ๅˆ— A A = list(map(int, A.split())) flag = 1 # ้€†ใฎ้šฃๆŽฅ่ฆ็ด ใŒๅญ˜ๅœจใ™ใ‚‹ count = 0 # ไบคๆ›ๅ›žๆ•ฐ while flag: flag = 0 for j in range(N-1, 0, -1): if A[j] < A[j-1]: # A[j] ใจ A[j-1] ใ‚’ไบคๆ› tmp = A[j] A[j] = A[j-1] A[j-1] = tmp flag = 1 count += 1 print(" ".join(map(str,A))) print(count) N = int(input()) A = input() bubbleSort(A, N)
s829855158
p02259
u405478089
1527214454
Python
Python
py
Runtime Error
0
0
564
def bubbleSort(A, N): # N ๅ€‹ใฎ่ฆ็ด ใ‚’ๅซใ‚€ 0-ใ‚ชใƒชใ‚ธใƒณใฎ้…ๅˆ— A A = list(map(int, A.split())) flag = 1 # ้€†ใฎ้šฃๆŽฅ่ฆ็ด ใŒๅญ˜ๅœจใ™ใ‚‹ count = 0 # ไบคๆ›ๅ›žๆ•ฐ while flag: flag = 0 for j in range(N-1, 0, -1): if A[j] < A[j-1]: # A[j] ใจ A[j-1] ใ‚’ไบคๆ› tmp = A[j] A[j] = A[j-1] A[j-1] = tmp flag = 1 count += 1 print(" ".join(map(str,A))) print(count) N = int(input()) A = input() bubbleSort(A, N)
s960489017
p02259
u405478089
1527214666
Python
Python
py
Runtime Error
0
0
485
N = int(input()) #่ฆ็ด ๆ•ฐ A = list(map(int,input().split())) #ใ‚ฝใƒผใƒˆๅฏพ่ฑก๏ผˆใ‚นใƒšใƒผใ‚นๅŒบๅˆ‡ใ‚Šโ†’้…ๅˆ—ใซๅฑ•้–‹๏ผ‰ flag = 1 i = 0 cnt = 0 #Sortๅ‡ฆ็†๏ผˆ่‡ชๅˆ†ใƒกใƒข๏ผšflagใŒ0ใซใชใฃใŸใ‚‰ใƒซใƒผใƒ—ใ‚’ๆŠœใ‘ใ‚‹๏ผ‰ while flag: flag = 0 for j in reversed(range(i+1,N)): if A[j] < A[j-1]: tmp = A[j-1] A[j-1] = A[j] A[j] = tmp flag = 1 cnt += 1 i += 1 print(' '.join(map(str,A))) print(cnt)
s643830227
p02259
u405478089
1527214769
Python
Python
py
Runtime Error
0
0
565
def bubbleSort(A, N): # N ๅ€‹ใฎ่ฆ็ด ใ‚’ๅซใ‚€ 0-ใ‚ชใƒชใ‚ธใƒณใฎ้…ๅˆ— A A = list(map(int, A.split())) flag = 1 # ้€†ใฎ้šฃๆŽฅ่ฆ็ด ใŒๅญ˜ๅœจใ™ใ‚‹ count = 0 # ไบคๆ›ๅ›žๆ•ฐ while flag: flag = 0 for j in range(N-1, 0, -1): if A[j] < A[j-1]: # A[j] ใจ A[j-1] ใ‚’ไบคๆ› tmp = A[j] A[j] = A[j-1] A[j-1] = tmp flag = 1 count += 1 print(" ".join(map(str,A))) print(count) N = int(input()) A = input() bubbleSort(A, N)
s139047722
p02259
u298224238
1529381106
Python
Python3
py
Runtime Error
0
0
322
N = int(input()) arr = [int(input()) for i in range(N)] swap_cnt = 0 i = 0 while True: swap_flg = False for j in range(N - 1, i + 1, -1): if (arr[j] < arr[j - 1]): arr[j], arr[j - 1] = arr[j - 1], arr[j] swap_cnt += 1 swap_flg = True if (!swap_flg): break
s577708885
p02259
u153665391
1529711164
Python
Python3
py
Runtime Error
0
0
309
N = int(input()) A = list(map(int, input().split())) if __name__ == '__main__': cnt = 0 for i in range(N): for j in range(N-1, i, -1): if j > 0 and A[j-1] > A[j]: A[j-1], A[j] = A[j], A[j-1] cnt += 1 print(" ".join(map(str, A))) pritn(cnt)
s175142122
p02259
u148477094
1530107339
Python
Python3
py
Runtime Error
0
0
163
n=int(input()) a=map(int,input().split()) b=0 for_in range(a): for i in range(n-1,0,-1): if a[i]<a[i-1]: a[i],a[i-1]=a[i-1],a[i] b=b+1 print(*a) print(b)
s496168587
p02259
u148477094
1530107647
Python
Python3
py
Runtime Error
0
0
189
n=int(input()) a=list(map(int,input().split()) b=0 for _ in a: for i in range(n-1,0,-1): if a[i]<a[i-1]: a[i],a[i-1]=a[i-1],a[i] b+=1 print(*a) print(b)
s916729061
p02259
u148477094
1530107807
Python
Python3
py
Runtime Error
0
0
189
n=int(input()) a=list(map(int,input().split()) b=0 for _ in a: for i in range(n-1,0,-1): if a[i]<a[i-1]: a[i],a[i-1]=a[i-1],a[i] b+=1 print(*a) print(b)
s031225496
p02259
u316584871
1530171367
Python
Python3
py
Runtime Error
0
0
488
n = int(input()) nlist = list(map(int, input().split())) def BubbleSort(C, n): c = 0 for i in range(n-1): for w in range(i+1, n): j = n-k+i if (C[j] < C[j-1]): a = C[j] C[j] = C[j-1] C[j-1] = a c += 1 BubbleSort(nlist, n) for i in range(n): if (i == n-1): print('{}'.format(nlist[i]), end = '') else : print('{}'.format(nlist[i]), end = ' ') print() print(c)
s346341763
p02259
u266872031
1384601984
Python
Python
py
Runtime Error
0
0
369
import sys #A=[[5],[4,5,2,3,1]] for line in sys.stdin: line=line.split() line=map(int,line) A.append(line) N=A[0][0] B=A[1] n=0 for i in range (N): for k in range(N-i-1): print k j=(N-2)-k if B[j]>B[j+1]: C=B[j] B[j]=B[j+1] B[j+1]=C n=n+1 E=map(str,B) D=" ".join(E) print n print D
s274122517
p02260
u462873421
1535539691
Python
Python
py
Runtime Error
0
0
455
def insection_sort(lst): lens=len(lst) ans=0 for i in xrange(lens): mn=i for j in xrange(i+1,lens): if(lst[j]<lst[mn]): mn=j if(mn!=i):lens tmp=lst[i] lst[i]=lst[mn] lst[mn]=tmp ans+=1 return ans num=int(raw_input().strip()) arr=map(int,raw_input().strip().split()) ans=insection_sort(arr) print " ".join(str(pp) for pp in arr) print ans
s414570943
p02260
u462873421
1535539752
Python
Python
py
Runtime Error
0
0
455
def insection_sort(lst): lens=len(lst) ans=0 for i in xrange(lens): mn=i for j in xrange(i+1,lens): if(lst[j]<lst[mn]): mn=j if(mn!=i):lens tmp=lst[i] lst[i]=lst[mn] lst[mn]=tmp ans+=1 return ans num=int(raw_input().strip()) arr=map(int,raw_input().strip().split()) ans=insection_sort(arr) print " ".join(str(pp) for pp in arr) print ans
s637063261
p02260
u817568302
1546258579
Python
Python
py
Runtime Error
0
0
383
def selectionSort(A, N): global cnt for i in range(N): minj = i for j in range(i, N): if A[j] < A[minj]: minj = j if i != minj: tmp = A[i] A[i] = A[minj] A[minj] = tmp cnt = cnt + 1 # return A if __name__ == '__main__': n = int(input()) R = list(map(int, input().split())) cnt = 0 R = selectionSort(R, n) print(" ".join(map(str, R))) print(cnt)
s046268290
p02260
u908238078
1546422114
Python
Python3
py
Runtime Error
0
0
606
#include<iostream> int selection_sort(int A[], int N) { int i, j, tmp, sw = 0, min_i; for (i = 0; i < N-1; i++) { min_i = i; for (j = i+1; j < N; j++) { if (A[j] < A[min_i]) min_i = j; } tmp = A[i]; A[i] = A[min_i]; A[min_i] = tmp; if (i != min_i) sw++; } return sw; } int main() { int A[100], i, N, sw; std::cin >> N; for (i = 0; i < N; i++) std::cin >> A[i]; sw = selection_sort(A, N); for (i = 0; i < N; i++) { if (i > 0) std::cout << ' '; std::cout << A[i]; } std::cout << std::endl; std::cout << sw << std::endl; return 0; }
s720163109
p02260
u698762975
1555786082
Python
Python3
py
Runtime Error
20
5592
314
def selectionsort(l,n): c=0 for i in range(n): minj=i for j in range(i,n): if int(l[i])<int(l[minj]): minj=j l[j],l[minj]=l[minj],l[j] if j!=minj: c+=1 print("".join(l)) print(c) n=int(input()) l=list(input()) selectionsort(l,n)
s301599673
p02260
u482227082
1559133863
Python
Python3
py
Runtime Error
0
0
360
ef main(): n = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(n): tmp = i for j in range(i, n): if a[j] < a[tmp]: tmp = j if i != tmp: a[i], a[tmp] = a[tmp], a[i] ans += 1 print(*a) print(ans) if __name__ == '__main__': main()
s007471950
p02260
u535719732
1559404373
Python
Python3
py
Runtime Error
0
0
229
n = int(input()) a = list(map(int,input())) c = 0 min = 9 for i in range(0,n): minj = i for j in range(i+1,n): if a[j] < a[minj]: minj = j a[i],a[minj] = a[minj],a[j] c += 1 print(*a) print(c)
s008471617
p02260
u535719732
1559404463
Python
Python3
py
Runtime Error
0
0
234
n = int(input()) a = list(map(int,input())) c = 0 min = 9 for i in range(0,n): minj = i for j in range(i+1,n): if a[j] < a[minj]: minj = j a[i],a[minj] = a[minj],a[j] c += 1 print(*a) print(c)
s933394991
p02260
u481221703
1419606968
Python
Python
py
Runtime Error
0
0
264
n = raw_input() A = map(int, raw_input().split()) cnt = 0 for i in xrange(len(A)-1): mini = i for j = i in xrange(len(A)-1): if A[j] < A[mini] mini = j A[i], A[mini] = A[mini], A[j] cnt += 1 for x in A: print x, print print cnt
s371744264
p02260
u481221703
1419607073
Python
Python
py
Runtime Error
0
0
263
n = raw_input() A = map(int, raw_input().split()) cnt = 0 for i in xrange(len(A)-1): mini = i for j in xrange(i, len(A)-1): if A[j] < A[mini] mini = j A[i], A[mini] = A[mini], A[j] cnt += 1 for x in A: print x, print print cnt
s793264474
p02260
u571345655
1436259678
Python
Python
py
Runtime Error
0
0
367
coding: utf-8 def selectionSort(A, N): count = 0 for i in xrange(N): minj = i for j in xrange(i, N): if A[j] < A[minj]: minj = j if minj != i: A[i], A[minj] = A[minj], A[i] count += 1 return count def main(): N = input() A = map(int, raw_input().split()) print selectionSort(A, 6) print ' '.join(map(str, A)) if __name__ == '__main__':
s087990458
p02260
u571345655
1436259752
Python
Python
py
Runtime Error
0
0
368
# coding: utf-8 def selectionSort(A, N): count = 0 for i in xrange(N): minj = i for j in xrange(i, N): if A[j] < A[minj]: minj = j if minj != i: A[i], A[minj] = A[minj], A[i] count += 1 return count def main(): N = input() A = map(int, raw_input().split()) print selectionSort(A, 6) print ' '.join(map(str, A)) if __name__ == '__main__':
s417267999
p02260
u571345655
1436259786
Python
Python
py
Runtime Error
0
0
374
# coding: utf-8 def selectionSort(A, N): count = 0 for i in xrange(N): minj = i for j in xrange(i, N): if A[j] < A[minj]: minj = j if minj != i: A[i], A[minj] = A[minj], A[i] count += 1 return count def main(): N = input() A = map(int, raw_input().split()) print selectionSort(A, 6) print ' '.join(map(str, A)) if __name__ == '__main__': main()
s881166417
p02260
u571345655
1436259870
Python
Python
py
Runtime Error
0
0
374
# coding: utf-8 def selectionSort(A, N): count = 0 for i in xrange(N): minj = i for j in xrange(i, N): if A[j] < A[minj]: minj = j if minj != i: A[i], A[minj] = A[minj], A[i] count += 1 return count def main(): N = input() A = map(int, raw_input().split()) print selectionSort(A, 6) print ' '.join(map(str, A)) if __name__ == '__main__': main()
s164131706
p02260
u313994256
1442290445
Python
Python
py
Runtime Error
0
0
315
N = int(raw_input()) num_list = map(int, raw_input().split()) c = 0 for i in range(0,N,1): minj =i for j in range(i,N,1) if num_list[j] < num_list[minj] minj = j a = num_list[i] num_list[i] = num_list[minj] num_list[minj] = a c += 1 print " ".join(map(str,num_list)) print c
s489719566
p02260
u313994256
1442290485
Python
Python
py
Runtime Error
0
0
317
N = int(raw_input()) num_list = map(int, raw_input().split()) c = 0 for i in range(0,N,1): minj =i for j in range(i,N,1): if num_list[j] < num_list[minj]: minj = j a = num_list[i] num_list[i] = num_list[minj] num_list[minj] = a c += 1 print " ".join(map(str,num_list)) print c
s371019687
p02260
u019737947
1442292611
Python
Python
py
Runtime Error
0
0
312
N = int(raw_input()) A = raw_input().split(" ") count = 0 for i in range(0, N): minj = i for j in range(i, N): if int(A[j]) < int(A[minj)]: minj = j if i != minj: temp = A[i] A[i] = A[minj] A[minj] = temp count += 1 print " ".join(A) print count
s272835099
p02260
u512342660
1464097460
Python
Python
py
Runtime Error
0
0
467
def show_list(a): for x in a: print x, print def selection_sort(a,n): count=0 for i in xrange(1,10): minj = i for j in xrange(i,n): if a[j]<a[minj]: minj = j tmp = a[i] a[i]=a[minj] a[minj]=tmp count+=1 show_list(a) print count def main(): n = input() a = map(int,raw_input().split()) selection_sort(a,n) if __name__ == '__main__': main()
s793039077
p02260
u611490888
1468180608
Python
Python
py
Runtime Error
0
0
495
# -*- coding: utf-8 -*- def selection_sort(A, N): for i in xrange(N): minj = i change = 0 for j in xrange(i, N): if A[j] < A[minj]: minj = j temp = A[minj] A[minj] = A[j] A[j] = temp change += 1 if __name__ == "__main__": N = input() A = map(int, raw_input().split()) result, change = selection_sort(A, N) print ' '.join(map(str, result)) print change
s361088637
p02260
u798803522
1472006320
Python
Python3
py
Runtime Error
0
0
379
length = int(input()) targ = [int(n) for n in input().split(' ')] ans = 0 for l in range(length): value = l for init in range(l + 1,length): if targ[value] > targ[init]: value = init if value != l: disp = targ[l] targ[l] = targ[value] targ[value] = disp ans += 1 print(' '.join([str(n) for n in targ])) print(ans)''
s611454266
p02260
u895660619
1487481412
Python
Python3
py
Runtime Error
0
0
264
N = int(input()) A = [int(x) for x in input().split()] num_c = 0 for i in (0, N): minj = i for j in (i, N): if A[j] < A[minj]: minj = j A[i], A[minj] = A[minj], A[j] num_c += 1 print((" ").join(str(x) for x in A)) print(num_c)
s541396407
p02260
u895660619
1487481451
Python
Python3
py
Runtime Error
0
0
264
N = int(input()) A = [int(x) for x in input().split()] num_c = 0 for i in (0, N): minj = i for j in (i, N): if A[j] < A[minj]: minj = j A[i], A[minj] = A[minj], A[j] num_c += 1 print((" ").join(str(x) for x in A)) print(num_c)
s705103663
p02260
u895660619
1487481502
Python
Python3
py
Runtime Error
0
0
264
N = int(input()) A = [int(x) for x in input().split()] num_c = 0 for i in (0, N): minj = i for j in (i, N): if A[j] < A[minj]: minj = j A[i], A[minj] = A[minj], A[i] num_c += 1 print((" ").join(str(x) for x in A)) print(num_c)
s220130716
p02260
u854976463
1488007223
Python
Python
py
Runtime Error
0
0
1938
# insertionSort # divide list into ordered part and part wait to sort # select one from part wait to sort and insert into ordered par t global r, signals r, signals = 0, False def insertionSort(A): global r, signals # Get length of A l = len(A) for i in range(l): # Selected i-th element to swap from 0 to n v = A[i] # j is point to tail of order j = i - 1 # Move forward, Control order of sorted while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 signals = True A[j+1] = v r += 1 if signals else 0 signals = False return A raw_input() res, l = "", 0 for i in insertionSort(map(int, raw_input().split())): res += (" " if l != 0 else "") + str(i) l += 1 print res, "\n", r
s837582628
p02260
u854976463
1488011518
Python
Python
py
Runtime Error
0
0
1522
# insertionSort # divide list into ordered part and part wait to sort # select one from part wait to sort and insert into ordered part def insertionSort(A): # Get length of A l, r = len(A), 0 for i in range(l): # Selected i-th element to swap from 0 to n v = A[i] # j is point to tail of order j = i - 1 # Move forward, Control order of sorted while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v r += (0 if i != j else 1) return A raw_input() res, l = "", 0 for i in insertionSort(map(int, raw_input().split())): res += (" " if l != 0 else "") + str(i) l += 1 print res print r
s425337711
p02260
u297744593
1493446952
Python
Python3
py
Runtime Error
0
0
376
#3.4 N = int(input()) a = list(map(int, input().split())) swapCount = 0 for i in range(0, N): minIndex = 1 for j in range(i + 1, N): if a[j] < a[minIndex]: minIndex = j if i != minIndex: tmp = a[i] a[i] = a[minIdex] a[minIndex] = tmp swapCount += 1 print(' '.join(map(str, a))) print(swapCount)
s712881242
p02260
u297744593
1493447008
Python
Python3
py
Runtime Error
0
0
372
#3.4 N = int(input()) a = list(map(int, input().split())) swapCount = 0 for i in range(0, N): minIndex = 1 for j in range(0, N): if a[j] < a[minIndex]: minIndex = j if i != minIndex: tmp = a[i] a[i] = a[minIdex] a[minIndex] = tmp swapCount += 1 print(' '.join(map(str, a))) print(swapCount)
s089435306
p02260
u650790815
1496031451
Python
Python3
py
Runtime Error
0
0
237
n = int(input()) a = list(map(int,input().strip().split())) for i in range(n): minj = i for j in range(i,n): if a[j] < a[minj]: minj = j a[i],a[minj] = a[minj],a[i] print(' '.join(map(str,a))) print(count)
s161259447
p02260
u650790815
1496032051
Python
Python3
py
Runtime Error
0
0
272
n = int(input()) a = list(map(int,input().split())) cnt = 0 for i in range(n): minj = i for j in range(i,n): if a[j] < a[minj]: minj = j a[i],a[minj] = a[minj],a[i] if i != minj: cnt += 1 print(' '.join(map(str,a))) print(count)
s921234608
p02260
u813534019
1497087386
Python
Python
py
Runtime Error
0
0
269
n=input() lst=input().split() cnt = 0 for i in range(0, len(lst)): m = i for j in range(i, len(lst)): if lst[m] > lst[j]: m = j if m != i: lst[i], lst[m] = lst[m], lst[i] cnt+=1 print (" ".join(map(str,lst))) print (cnt)
s665073464
p02260
u813534019
1497087745
Python
Python
py
Runtime Error
0
0
268
n=input() lst=input().split() cnt = 0 for i in range(0, len(lst)): m = i for j in range(i, len(lst)): if lst[m] > lst[j]: m = j if m != i: lst[i], lst[m] = lst[m], lst[i] cnt+=1 print " ".join(map(str,lst)) print (cnt)
s655929593
p02260
u747635679
1498212898
Python
Python3
py
Runtime Error
20
7628
315
n = int(input()) a = [int(x) for x in input().split()] c = 0 for i in range(n - 1): minj = i for j in (i + 1, n): if a[j] < a[minj]: minj = j if minj != i: tmp = a[i] a[i] = a[minj] a[minj] = tmp c += 1 print(" ".join([str(x) for x in a])) print(c)
s469056410
p02260
u844704750
1498962737
Python
Python3
py
Runtime Error
0
0
519
N = int(input()) A = list(map(int, input().split(" "))) def print_list(A): for a in A[:-1]: print ("%d "%a, end="") print(A[-1]) def SelectionSort(A, N): count = 0 for i in range(N): minj = i for j in range(i, N): if A[j] < A[minj]: minj = j if minj != i: v = A[i] A[i] = A[minj] A[minj] = v count += 1 return A, count A_sorted, c = BubbleSort(A, N) print_list(A_sorted) print(c)
s266189847
p02260
u343251190
1507468414
Python
Python3
py
Runtime Error
0
0
355
def selectionsort(A, N): count = 0 for i in range(N): min_a = min(A[i:]) min_index = A.index(min_a) A[i], A[min_index] = min_a, A[i] if (A[i] != A[min_index]): count += 1 return count def main(): n = int(input()) data = list(map(int, input().split())) c = selectionsort2(data, n) print(*data) print(c) if __name__ == "__main__": main()
s871353995
p02260
u514487486
1509157980
Python
Python3
py
Runtime Error
0
0
270
def SelectionSort(A): for i in range(len(A)): minj = i for j in range(i, range(A)): if A[j] < A[minj]: minj = j A[i], A[minj] = A[minj], A[i] n = int(input()) A = list(map(int, input().split())) SelectionSort(A)
s328211661
p02260
u514487486
1509158166
Python
Python3
py
Runtime Error
0
0
353
def SelectionSort(A): count = 0 for i in range(len(A)): minj = i for j in range(i, range(A)): if A[j] < A[minj]: minj = j A[i], A[minj] = A[minj], A[i] count += 1 print(" ".join(map(str, A))) print(count) n = int(input()) A = list(map(int, input().split())) SelectionSort(A)
s582272849
p02260
u626266743
1510021759
Python
Python3
py
Runtime Error
0
0
250
N = innt(input()) A = list(map(int, input().split())) count = 0 for i in range(0, N-1): minj = i for j in range(i, N-1): if (A[j] < A[minj]): minj = j A[i], A[minj] = A[minj], A[i] count += 1 print(*A) print(count)
s873015807
p02260
u424457654
1510031458
Python
Python3
py
Runtime Error
0
0
263
N = int(input()) a = list(map(int, input().split())) count = 0 for i in range(N) minj = i for j in range(i, N) if a[j] < a[minj] minj = j if a[i] != a[minj] a[minj], a[i] = a[i], a[minj] count += 1 print(" ".join(map(str, a))) print(count)
s277897054
p02260
u424457654
1510031540
Python
Python3
py
Runtime Error
0
0
244
N = int(input()) a = list(map(int, input().split())) count = 0 for i in range(N) minj = i for j in range(i, N) if a[j] < a[minj] minj = j if a[i] != a[minj] a[minj], a[i] = a[i], a[minj] count += 1 print(*a) print(count)
s471283481
p02260
u433154529
1510992826
Python
Python3
py
Runtime Error
20
7720
259
n=int(input()) a=[int(i) for i in input().split(" ")] x=0 for i in range(n): mi=i for j in range(i,n): if a[j] < a[mi]: mi = j if i != mi: x+=1 a[i],a[mi]=a[mi],[i] print(" ".join([str(i) for i in a])) print(x)
s053924637
p02260
u865281338
1511749332
Python
Python3
py
Runtime Error
0
0
459
def main() : n = int(input()) nums = [int(i) for i in input().split()] exchange_count = 0 for i in range(n) : minj = i for j in range(i,n) : if nums[j] < nums[minj] : minj = j if minj != i : exchange_count += 1 nums[i], nums[minj] = nums[minj], nums[i] print(" ".join(map(str, nums))) print(excnage_count) if __name__ == '__main__' : main()
s207034444
p02260
u865281338
1511749441
Python
Python3
py
Runtime Error
0
0
447
def main() : n = int(input()) nums = [int(i) for i in input().split()] exchange_count = 0 for i in range(n) : minj = i for j in range(i,n) : if nums[j] < nums[minj] : minj = j if minj != i : exchange_count += 1 nums[i], nums[minj] = nums[minj], nums[i] print(" ".join(map(str, nums))) print(excnage_count) if __name__ == '__main__' : main()
s398431720
p02260
u865281338
1511749547
Python
Python3
py
Runtime Error
0
0
447
def main() : n = int(input()) nums = [int(i) for i in input().split()] exchange_count = 0 for i in range(n) : minj = i for j in range(i,n) : if nums[j] < nums[minj] : minj = j if minj != i : exchange_count += 1 nums[i], nums[minj] = nums[minj], nums[i] print(" ".join(map(str, nums))) print(excnage_count) if __name__ == '__main__' : main()
s172629701
p02260
u865281338
1511749637
Python
Python3
py
Runtime Error
0
0
448
def main() : n = int(input()) nums = [int(i) for i in input().split()] exchange_count = 0 for i in range(n) : minj = i for j in range(i, n) : if nums[j] < nums[minj] : minj = j if minj != i : exchange_count += 1 nums[i], nums[minj] = nums[minj], nums[i] print(" ".join(map(str, nums))) print(excnage_count) if __name__ == '__main__' : main()
s491967658
p02260
u865281338
1511749724
Python
Python3
py
Runtime Error
0
0
448
def main() : n = int(input()) nums = [int(i) for i in input().split()] exchange_count = 0 for i in range(n) : minj = i for j in range(i, n) : if nums[j] < nums[minj] : minj = j if minj != i : exchange_count += 1 nums[i], nums[minj] = nums[minj], nums[i] print(" ".join(map(str, nums))) print(exchage_count) if __name__ == '__main__' : main()
s157223496
p02260
u424041287
1512122286
Python
Python3
py
Runtime Error
0
0
389
def selectionSort(A, N): s = 0 for i in range(N): minj = i for j in range(i,N): if A[j] < A[minj]: minj = j A[i], A[minj] = A[minj], A[i] s += 1 t = str(A[0]) for i in range(1,N): t = t + " " + str(A[i]) print(t) print(s) n = int(input()) a = [int(i) for i in input().split()] slectionSort(a, n)
s137793775
p02260
u424041287
1512122300
Python
Python3
py
Runtime Error
0
0
389
def selectionSort(A, N): s = 0 for i in range(N): minj = i for j in range(i,N): if A[j] < A[minj]: minj = j A[i], A[minj] = A[minj], A[i] s += 1 t = str(A[0]) for i in range(1,N): t = t + " " + str(A[i]) print(t) print(s) n = int(input()) a = [int(i) for i in input().split()] slectionSort(a, n)
s618442050
p02260
u608789460
1518848666
Python
Python3
py
Runtime Error
0
0
251
n=int(input()) nums=list(map(int,input())) count=0 for i in range(n): minj=i for j in range(i,n): if nums[j] < nums[minj]: minj=j nums[i]=v nums[i]=nums[minj] nums[minj]=v count+=1 print(*nums) print(count)
s442189814
p02260
u608789460
1518849019
Python
Python
py
Runtime Error
0
0
287
n=int(input()) nums=list(map(int,input())) count=0 for i in range(n): minj=i for j in range(i,n): if nums[j] < nums[minj]: minj=j if not i==minj: v=nums[i] nums[i]=nums[minj] nums[minj]=v count+=1 print(*nums) print(count)
s287448068
p02260
u691071335
1522755611
Python
Python
py
Runtime Error
0
0
563
# include <stdio.h> int main(){ int N = 0; scanf("%d", &N); int a[N]; for(int i=0; i<N; ++i){ scanf("%d", &a[i]); } // selection sort int swap = 0; for(int i=0; i<N-1; ++i){ int min = i; for(int j=i+1; j<N; ++j){ if(a[j] > a[min]){ min = j; } } int tmp = a[i]; a[i] = a[min]; a[min] = tmp; swap++; } for(int i=0; i<N-1; ++i){ printf("%d ", a[i]); } printf("%d\n", a[N-1]); printf("%d\n", swap); }
s792364131
p02260
u724548524
1524969141
Python
Python3
py
Runtime Error
0
0
246
import numpy as np n = int(input()) a = np.array(list(map(int, input().split()))) c = 0 for i in range(n - 1): j = np.argmin(a[i:]) + i if i != j: a[i], a[j] = a[j], a[i] c += 1 print(" ".join(map(str, list(a)))) print(c)
s989797224
p02260
u724548524
1524969211
Python
Python3
py
Runtime Error
0
0
246
import numpy as np n = int(input()) a = np.array(list(map(int, input().split()))) c = 0 for i in range(n - 1): j = np.argmin(a[i:]) + i if i != j: a[i], a[j] = a[j], a[i] c += 1 print(" ".join(map(str, list(a)))) print(c)
s355752085
p02260
u298224238
1529382535
Python
Python3
py
Runtime Error
0
0
324
N = int(input()) arr = [int(n) for n in input().split()] swap_cnt = 0 for i in range(0, N): minj = i for j in range(i + 1, N - 1): if A[j] < A[minj] minj = j arr[i], arr[minj] = arr[minj], arr[i] swap_cnt += 1 if i != minj else 0 print(' '.join(map(str, arr))) print(swap_cnt)
s821653988
p02260
u298224238
1529382573
Python
Python3
py
Runtime Error
0
0
333
N = int(input()) arr = [int(n) for n in input().split()] swap_cnt = 0 minj = 0 for i in range(0, N): minj = i for j in range(i + 1, N - 1): if A[j] < A[minj] minj = j arr[i], arr[minj] = arr[minj], arr[i] swap_cnt += 1 if i != minj else 0 print(' '.join(map(str, arr))) print(swap_cnt)
s844223642
p02260
u298224238
1529382595
Python
Python3
py
Runtime Error
0
0
328
N = int(input()) arr = [int(n) for n in input().split()] swap_cnt = 0 for i in range(0, N): minj = i for j in range(i + 1, N - 1): if arr[j] < arr[minj] minj = j arr[i], arr[minj] = arr[minj], arr[i] swap_cnt += 1 if i != minj else 0 print(' '.join(map(str, arr))) print(swap_cnt)
s295461605
p02260
u148477094
1530109189
Python
Python3
py
Runtime Error
0
0
241
n=int(input()) a=list(map(int,input().split())) b=0 for i in range(n): minj=i for j in range(i+1,n-1): if a[minj]>a[j]: minj=j if i!=minj: a[i],a[minj]=a[minj],a[i] b+=1 print(*a) print(b)
s210231717
p02260
u148477094
1530109228
Python
Python3
py
Runtime Error
0
0
243
n=int(input()) a=list(map(int,input().split())) b=0 for i in range(n-1): minj=i for j in range(i+1,n-1): if a[minj]>a[j]: minj=j if i!=minj: a[i],a[minj]=a[minj],a[i] b+=1 print(*a) print(b)
s918103083
p02260
u148477094
1530109267
Python
Python3
py
Runtime Error
0
0
243
n=int(input()) a=list(map(int,input().split())) b=0 for i in range(n-1): minj=i for j in range(i+1,n-1): if a[minj]>a[j]: minj=j if i!=minj: a[i],a[minj]=a[minj],a[i] b+=1 print(*a) print(b)
s952185602
p02260
u633068244
1393745902
Python
Python
py
Runtime Error
0
0
343
def ss(n, a): count = 0 for i in range(n): mini = i for j in range(i,n): if a[j] < a[mini]: mini = j if i != mini: a[i], a[mini] = a[mini], a[i] count += 1 print " ".join(map(str, a)) print count ss(int(raw_input()), map(int, raw_inpu().split()))