buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
N = eval(input()) A = list(map(int, input().split())) ans = 0 for i in range(N): minj = i for j in range(i, N): if A[j] < A[minj]: minj = j if i != minj: ans += 1 A[i], A[minj] = A[minj], A[i] print(' '.join(map(str, A))) print(ans+1)
N = eval(input()) A = list(map(int, input().split())) ans = 0 for i in range(N): minj = i for j in range(i, N): if A[j] < A[minj]: minj = j if i != minj: ans += 1 A[i], A[minj] = A[minj], A[i] print(' '.join(map(str, A))) print(ans)
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
112
2
def select_sort(array): N = len(array) count = 0 for i in range(N - 1): min_i = array.index(min(array[i:])) if i != min_i: count += 1 array[i], array[min_i] = array[min_i], array[i] return array, count n = int(input()) array = [int(i) for i in input().s...
def select_sort(array): N = len(array) count = 0 for i in range(N - 1): min_i = i + array[i:].index(min(array[i:])) if i != min_i: count += 1 array[i], array[min_i] = array[min_i], array[i] return array, count n = int(input()) array = [int(i) for i in i...
[["+", 8, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 12, 657, 12, 652, 63, 319, 500, 206, 0, 70], ["+", 12, 652, 63, 319, 500, 206, 206, 663, 0, 22], ["+", 12, 652, 63, 319, 500, 206, 206, 663, 0, 102], ["+", 12, 657, 12, 652, 63, 319, 500, 206, 0, 73]]
5
118
6
def selectionSort(n, A): cnt =0 for i in range(n): minj = i for j in range(i,n): if A[minj] > A[j]: minj = j A[i],A[minj] = A[minj],A[i] cnt += 1 print(*A) print(cnt) if __name__ == '__main__': n = int(input()) A = list(map(int, input(...
def selectionSort(n, A): cnt =0 for i in range(n): minj = i for j in range(i,n): if A[minj] > A[j]: minj = j if i != minj: A[i],A[minj] = A[minj],A[i] cnt += 1 print(*A) print(cnt) if __name__ == '__main__': n = int(input()...
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 102]]
5
115
5
def selectionSort(A, N): swap_count = 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] swap_count += 1 return swap_count n = int(input()) A = list(map(int, input().split())) count = sele...
def selectionSort(A, N): swap_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: A[i], A[minj] = A[minj], A[i] swap_count += 1 return swap_count n = int(input()) A = list(map(int, ...
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 102]]
5
112
5
N = int(input()) A = list(map(int, input().split())) def selectionSort(A, N): count = 0 for i in range(0, N): minj = i for j in range(i, N): if A[j] < A[minj]: minj = j temp = A[i] A[i] = A[minj] A[minj] = temp count += 1 return co...
N = int(input()) A = list(map(int, input().split())) def selectionSort(A, N): count = 0 for i in range(0, N): minj = i for j in range(i, N): if A[j] < A[minj]: minj = j if i != minj: temp = A[i] A[i] = A[minj] A[minj] = tem...
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 102]]
5
127
5
def pretty_sequence(sequence): n = len(sequence) for i in range(n-1): print(format(sequence[i]) + ' ', end='') print(sequence[n - 1]) n = int(input()) sequence = [int(x) for x in input().split(' ')] def selectionsort(seq, x): count = 0 for i in range(x): minj = i for j in ...
def pretty_sequence(sequence): n = len(sequence) for i in range(n-1): print(format(sequence[i]) + ' ', end='') print(sequence[n - 1]) n = int(input()) sequence = [int(x) for x in input().split(' ')] def selectionsort(seq, x): count = 0 for i in range(x): minj = i for j in ...
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
186
4
#3.4 N = int(input()) a = list(map(int, input().split())) swapCount = 1 for i in range(0, N): minIndex = i for j in range(0, N): if a[j] < a[minIndex]: minIndex = j if i != minIndex: tmp = a[i] a[i] = a[minIndex] a[minIndex] = tmp swapCount += 1 pr...
#3.4 N = int(input()) a = list(map(int, input().split())) swapCount = 0 for i in range(0, N): minIndex = i for j in range(i, N): if a[j] < a[minIndex]: minIndex = j if i != minIndex: tmp = a[i] a[i] = a[minIndex] a[minIndex] = tmp swapCount += 1 pr...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22]]
5
115
4
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)
n = int(input()) a = [int(x) for x in input().split()] c = 0 for i in range(n - 1): minj = i for j in range(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)
[["+", 0, 7, 8, 196, 0, 7, 12, 652, 63, 22]]
5
120
1
def selection_sort(A, N): sw = 0 for i in range(N): minj = i for j in range(i, N): if A[j] < A[minj]: minj = j sw += 1 A[i], A[minj] = A[minj], A[i] return sw def main(): N = int(input().rstrip()) A = list(map(int, input().rstrip(...
def selection_sort(A, N): sw = 0 for i in range(N): minj = i for j in range(i, N): if A[j] < A[minj]: minj = j if minj != i: sw += 1 A[i], A[minj] = A[minj], A[i] return sw def main(): N = int(input().rstrip()) A = list(ma...
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 102]]
5
146
5
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 ...
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 ...
[["-", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22]]
5
162
2
N = int(input()) A = list(map(int, input().split())) cnt = 0 for i in range(N): # i ?????????????????¨???????????? minj = i for j in range(i, N): # ?????????????????¨??????????°??????????????????? if A[j] < A[minj]: minj = j # ??????????????¨??????????°??????????????????????...
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 if i is not minj: A[i], A[minj] = A[minj], A[i] cnt += 1 print(' '.join(map(str, A))) print(cnt)
[["+", 0, 656, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 694], ["+", 0, 656, 0, 7, 8, 196, 0, 57, 0, 102]]
5
108
6
n = int(input()) data = [int(s) for s in input().split()] change = 0 new = [] for idx in range(n): idx_min = data.index(min(data[idx:])) if idx_min > idx: data[idx],data[idx_min] = data[idx_min],data[idx] change += 1 print(' '.join([str(d) for d in data])) print(change)
n = int(input()) data = [int(s) for s in input().split()] change = 0 new = [] for idx in range(n): idx_min = data[idx:].index(min(data[idx:])) + idx if idx_min > idx: data[idx],data[idx_min] = data[idx_min],data[idx] change += 1 print(' '.join([str(d) for d in data])) print(change)
[["+", 12, 657, 31, 652, 63, 319, 500, 206, 0, 70], ["+", 31, 652, 63, 319, 500, 206, 206, 663, 0, 22], ["+", 31, 652, 63, 319, 500, 206, 206, 663, 0, 102], ["+", 12, 657, 31, 652, 63, 319, 500, 206, 0, 73], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22]]
5
107
6
def selections(N): count = 0 for i in range(len(N)): mini = i for j in range(i+1, len(N)): if N[mini] > N[j]: mini = j if i != mini: N[mini], N[i] = N[i], N[mini] c = 1 for i in N: print(i, end='') if c < len(N): ...
def selections(N): count = 0 for i in range(len(N)): mini = i for j in range(i+1, len(N)): if N[mini] > N[j]: mini = j if i != mini: N[mini], N[i] = N[i], N[mini] count += 1 c = 1 for i in N: print(i, end='') if ...
[["+", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 12, 612]]
5
153
3
def SelectionSort(A): count = 0 for i in range(len(A)): minj = i for j in range(i, len(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, inpu...
def SelectionSort(A): count = 0 for i in range(len(A)): minj = i for j in range(i, len(A)): if A[j] < A[minj]: minj = j if i != minj: A[i], A[minj] = A[minj], A[i] count += 1 print(" ".join(map(str, A))) print(count) n = int(i...
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 102]]
5
121
5
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 (minj != i): A[i], A[minj] = A[minj], A[i] count += 1 print(*A) print(count)
N = int(input()) A = list(map(int, input().split())) count = 0 for i in range(N): m = i for j in range(i, N): if (A[j] < A[m]): m = j if (m != i): A[i], A[m] = A[m], A[i] count += 1 print(*A) print(count)
[["-", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 57, 15, 23, 0, 666, 0, 206, 206, 22], ["+", 0, 57, 15, 23, 0, 666, 0, 206, 206, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["-", 64, 196, 0, 57, 15, 23, 0, 666, 0, 22], ["+...
5
103
12
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[mi...
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[m...
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]]
5
126
2
i=input N=int(i()) A=list(map(int,i().split())) r = range c=0 for i in r(N): minj=i for j in r(i,N): if A[j] < A[minj]: minj = j c+=1 A[i],A[minj] = A[minj],A[i] print(*A) print(c)
i=input N=int(i()) A=list(map(int,i().split())) r = range c=0 for i in r(N): minj=i for j in r(i,N): if A[j] < A[minj]: minj = j if i !=minj: c+=1 A[i],A[minj] = A[minj],A[i] print(*A) print(c)
[["+", 0, 656, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 0, 656, 0, 7, 8, 196, 0, 57, 0, 102]]
5
100
5
def selection_sort(A): n = len(A) swap_cnt = 0 for i in range(n): mini = i for j in range(i, n): if A[j] < A[mini]: mini = j A[i], A[mini] = A[mini], A[i] swap_cnt += 1 return A, swap_cnt n = int(input()) A = list(map(int, input().split())) A,...
def selection_sort(A): n = len(A) swap_cnt = 0 for i in range(n): mini = i for j in range(i, n): if A[j] < A[mini]: mini = j if mini != i: A[i], A[mini] = A[mini], A[i] swap_cnt += 1 return A, swap_cnt n = int(input()) A = list...
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 102]]
5
132
5
n=int(input()) a=list(map(int,input().split())) b=c=0 for i in range(n-1): m=a.index(min(a[i:])) if a[i]>a[m]: a[i],a[m]=a[m],a[i];c+=1 print(*a) print(c)
n=int(input()) a=list(map(int,input().split())) c=0 for i in range(n-1): m=a.index(min(a[i:]),i) if a[i]>a[m]: a[i],a[m]=a[m],a[i];c+=1 print(*a) print(c)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
98
19
count = int(input()); data = [int(n) for n in input().split(" ")]; def selection_sort(data): count = len(data); o = 0; for i in range(count): minI = i; for j in range(i + 1, count): if data[j] < data[minI]: minI = j; temp = data[i]; data[i] = data...
count = int(input()); data = [int(n) for n in input().split(" ")]; def selection_sort(data): count = len(data); o = 0; for i in range(count): minI = i; for j in range(i + 1, count): if data[j] < data[minI]: minI = j; if minI != i: temp = data[...
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 102]]
5
155
5
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=i if i!=minj: a[i],a[minj]=a[minj],a[i] b+=1 print(*a) print(b)
n=int(input()) a=list(map(int,input().split())) b=0 for i in range(n): minj=i for j in range(i,n): if a[minj]>a[j]: minj=j if i!=minj: a[i],a[minj]=a[minj],a[i] b+=1 print(*a) print(b)
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 12, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 22]]
5
103
6
#!/usr/bin/python i = eval(input()) n = list(map(int, input().split())) cnt=0 for i in range(len(n)): min = i flag = False for j in range(i, len(n)): if n[j] < n[min]: min=j flag = True n[i],n[min] = n[min],n[i] cnt+=1 print(' '.join(map(str,n))) print(cnt)
#!/usr/bin/python i = eval(input()) n = list(map(int, input().split())) cnt=0 for i in range(len(n)): min = i # flag = False flag = 0 for j in range(i, len(n)): if n[j] < n[min]: min=j # flag = True flag = 1 n[i],n[min] = n[min],n[i] cnt+=flag print(' ...
[["-", 0, 7, 8, 196, 0, 1, 0, 662, 12, 147], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 12, 146], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612], ["-", 0, 7, 8, 196, 0, 1, 0, 677, 12, 612], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 12, 22]]
5
118
6
#!/usr/bin/python # -*- coding: UTF-8 -*- i = eval(input()) n = list(map(int, input().split())) cnt=0 #リストの一番手前からみる。 for i in range(len(n)): #いま見てる番目を記憶 min=i #フラグ判定を0で初期化 flag=0 #リストの二番目から最後は一つ手前まで for j in range(1,len(n)): if n[j]<n[min]: #より小さい値の順番目を記憶する。 #このifの中に入っていると入れ替え処理候補が有ったことになるのでフラグを立てる...
#!/usr/bin/python # -*- coding: UTF-8 -*- i = eval(input()) n = list(map(int, input().split())) cnt=0 #リストの一番手前からみる。 for i in range(len(n)): #いま見てる番目を記憶 min=i #フラグ判定を0で初期化 flag=0 #リストの二番目から最後は一つ手前まで for j in range(i,len(n)): if n[j]<n[min]: #より小さい値の順番目を記憶する。 #このifの中に入っていると入れ替え処理候補が有ったことになるのでフラグを立てる...
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22]]
5
126
2
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 a[i], a[mini] = a[mini], a[i] count += 1 if i == mini else 0 return count, a n = int(input()) a = list(map(int, input().split())) n, a = SS(n...
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 a[i], a[mini] = a[mini], a[i] count += 1 if i != mini else 0 return count, a n = int(input()) a = list(map(int, input().split())) n, a = SS(n...
[["-", 0, 1, 0, 677, 12, 41, 0, 666, 667, 60], ["+", 0, 1, 0, 677, 12, 41, 0, 666, 667, 79]]
5
133
2
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using namespace std; int cnt = 0; vector<int> G; void insertsort(int A[], int n, int g) { for (int i = g; i < n; i++) { int temp = A[i], j = i - g; while (j >= 0 && A[j] > temp) { A[j + g] = A[j]; j -= g; cnt++; ...
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using namespace std; int cnt = 0; vector<int> G; void insertsort(int A[], int n, int g) { for (int i = g; i < n; i++) { int temp = A[i], j = i - g; while (j >= 0 && A[j] > temp) { A[j + g] = A[j]; j -= g; cnt++; ...
[["-", 0, 14, 8, 9, 0, 7, 26, 27, 17, 29], ["+", 0, 14, 8, 9, 0, 7, 26, 27, 17, 68]]
1
350
2
#include <iostream> #include <vector> using namespace std; long long cnt; vector<int> G; void insertionSort(vector<int> &A, int g) { for (int i = g; i < A.size(); i++) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j -= g; cnt++; } A[j + g] = v; ...
#include <iostream> #include <vector> using namespace std; long long cnt; vector<int> G; void insertionSort(vector<int> &A, int g) { for (int i = g; i < A.size(); i++) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j -= g; cnt++; } A[j + g] = v; ...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22]]
1
353
2
// ConsoleApplication1.cpp : Defines the entry point for the console // application. // //#include "stdafx.h" #include <algorithm> #include <iostream> #include <vector> using namespace std; int cnt = 0; vector<int> g; int shell(int n) { int m = 0; for (int i = 1;; i = i * 2 + 1, m++) { if (i > n) break...
// ConsoleApplication1.cpp : Defines the entry point for the console // application. // //#include "stdafx.h" #include <algorithm> #include <iostream> #include <vector> using namespace std; long long cnt = 0; vector<int> g; int shell(int n) { int m = 0; for (int i = 1;; i = i * 3 + 1, m++) { if (i > n) ...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["-", 26, 34, 31, 11, 12, 16, 31, 16, 12, 13], ["+", 26, 34, 31, 11, 12, 16, 31, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
310
7
#include <iostream> #include <vector> using namespace std; int cnt = 0; int A[1000000]; vector<int> G; void insertionSort(int A[], int n, int g) { int cnt = 0; int v, j; for (int i = g; i < n; ++i) { v = A[i]; j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j -= g; cnt++; ...
#include <iostream> #include <vector> using namespace std; int cnt = 0; int A[1000000]; vector<int> G; void insertionSort(int A[], int n, int g) { int v, j; for (int i = g; i < n; ++i) { v = A[i]; j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j -= g; cnt++; } A[j ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19]]
1
322
7
#include <cstdio> #include <iostream> using namespace std; #define N 2 void InsertionSort(int *a, int n, int g); void ShellSort(int *a, int n); int a[1000005]; int cnt = 0; int main(void) { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } ShellSort(a, n); cout << cnt << endl; for (...
#include <cstdio> #include <iostream> using namespace std; #define N 2 void InsertionSort(int *a, int n, int g); void ShellSort(int *a, int n); int a[1000005]; int cnt = 0; int main(void) { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } ShellSort(a, n); cout << cnt << endl; for (...
[["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 19], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 18], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
370
4
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static int cnt = 0; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int length = scanner.nextInt(); int[] array = new int[length]; for (int i = 0; i < length...
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static int cnt = 0; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int length = scanner.nextInt(); int[] array = new int[length]; for (int i = 0; i < length...
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 8, 498, 0, 195, 8, 196, 0, 7, 0, 25], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], [...
3
411
9
#include <stdio.h> int n, cnt; int A[1000000]; int Insertionsort(int g) { int v; int i, j; for (i = g; i < n; i++) { v = A[i]; j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j -= g; cnt++; } A[j + g] = v; } } int Shellsort() { int G[100]; int i, m = 0, g =...
#include <stdio.h> int n, cnt; int A[1000000]; int Insertionsort(int g) { int v; int i, j; for (i = g; i < n; i++) { v = A[i]; j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j -= g; cnt++; } A[j + g] = v; } } int Shellsort() { int G[100]; int i, m = 0, g =...
[["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 69, 0, 70], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 69, 0, 73]]
0
311
5
#include <stdio.h> int cnt; void insertionSort(int A[], int n, int g); void shellSort(int A[], int n); int n; int A[1000000]; int main() { int i; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", A + i); shellSort(A, n); printf("%d\n", cnt); for (i = 0; i < n; i++) printf("%d\n", A[i]); ret...
#include <stdio.h> int cnt; void insertionSort(int A[], int n, int g); void shellSort(int A[], int n); int n; int A[1000000]; int main() { int i; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", A + i); shellSort(A, n); printf("%d\n", cnt); for (i = 0; i < n; i++) printf("%d\n", A[i]); ret...
[["-", 0, 14, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 2, 3, 4, 0, 69, 28, 5, 0, 6]]
0
361
5
#include <stdio.h> #define ASIZE 1048576 #define GSIZE 524288 int m, cnt = 0; int insertionSort(int *A, int n, int g) { int i, j, v; for (i = g; i < n; i++) { v = A[i]; j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j -= g; cnt++; } A[j + g] = v; } return cnt; }...
#include <stdio.h> #define ASIZE 1048576 #define GSIZE 524288 int m, cnt = 0; int insertionSort(int *A, int n, int g) { int i, j, v; for (i = g; i < n; i++) { v = A[i]; j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j -= g; cnt++; } A[j + g] = v; } return cnt; }...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
408
4
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <math.h> #include <stdio.h> #include <stdlib.h> int insertionSort(int A[], int N, int g, int cnt); void shellSort(int A[], int n); int main() { int *A, n, i; scanf("%d", &n); A = (int *)malloc(sizeof(int) * n); for (i = 0; i < n; ++i) scanf...
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <math.h> #include <stdio.h> #include <stdlib.h> int insertionSort(int A[], int N, int g, int cnt); void shellSort(int A[], int n); int main() { int *A, n, i; scanf("%d", &n); A = (int *)malloc(sizeof(int) * n); for (i = 0; i < n; ++i) scanf...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
0
466
2
#include <stdio.h> #include <stdlib.h> void insertionSort(int *A, int n, int g); void shellSort(int *A, int n); static int count; int main(void) { int i, n, *a; scanf("%d", &n); a = (int *)malloc(sizeof(int) * n); if (a == NULL) { printf("?????¢????¢??????¨??????\n"); return -1; } for (i = 0; i ...
#include <stdio.h> #include <stdlib.h> void insertionSort(int *A, int n, int g); void shellSort(int *A, int n); static int count; int main(void) { int i, n, *a; scanf("%d", &n); a = (int *)malloc(sizeof(int) * n); if (a == NULL) { printf("?????¢????¢??????¨??????\n"); return -1; } for (i = 0; i ...
[["+", 15, 23, 0, 16, 31, 16, 31, 16, 31, 13], ["+", 15, 23, 0, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 52, 15, 23, 0, 16, 31, 16, 17, 72], ["+", 0, 52, 15, 23, 0, 16, 31, 16, 12, 13], ["-", 0, 52, 15, 23, 0, 16, 12, 16, 17, 85], ["-", 0, 52, 15, 23, 0, 16, 12, 16, 12, 13]]
0
370
6
#include <stdio.h> int A[10000000]; int m, count = 0; int G[1000000]; void insert(int *A, int n, int g) { int v; int i, j; for (i = g; i < n; i++) { v = A[i]; j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j -= g; count++; } A[j + g] = v; } } void shell(int *A, i...
#include <stdio.h> int A[10000000]; int m, count = 0; int G[1000000]; void insert(int *A, int n, int g) { int v; int i, j; for (i = g; i < n; i++) { v = A[i]; j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j -= g; count++; } A[j + g] = v; } } void shell(int *A, i...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
0
354
2
#include <math.h> #include <stdio.h> #define MAX 1000000 int count = 0; int S[MAX]; int n, k, l; int G[MAX]; int Glen = 0; void insertSort() { int i, j; int u; for (i = 0; i < Glen; i++) { for (j = G[i]; j < n; j++) { u = S[j]; l = j - G[i]; while (l >= 0 && S[l] > u) { S[l + G[i]] ...
#include <math.h> #include <stdio.h> #define MAX 1000000 int count = 0; int S[MAX]; int n, k, l; int G[MAX]; int Glen = 0; void insertSort() { int i, j; int u; for (i = 0; i < Glen; i++) { for (j = G[i]; j < n; j++) { u = S[j]; l = j - G[i]; while (l >= 0 && S[l] > u) { S[l + G[i]] ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
418
2
/* Shell Sort */ #include <stdio.h> int main() { int A[1000000] = {0}, N, i, j, k, v, cnt = 0, m, G[100] = {0}; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%d", &A[i]); } i = 0; G[0] = 1; while (1) { if (G[i] > N) { m = 1; break; } else { G[i + 1] = (3 * G[i]) + 1; ...
/* Shell Sort */ #include <stdio.h> int main() { int A[1000000] = {0}, N, i, j, k, v, cnt = 0, m, G[100] = {0}; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%d", &A[i]); } i = 0; G[0] = 1; while (1) { if (G[i] > N) { m = i; break; } else { G[i + 1] = (3 * G[i]) + 1; ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]]
0
375
2
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> void insertionSort(int R[], int n, int g, int *cnt) { int i, v, j; for (i = g; i < n; i++) { v = R[i]; j = i - g; while (j >= 0 && R[j] > v) { R[j + g] = R[j]; j = j - g; (*cnt)++; //()をつける!! ...
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> void insertionSort(int R[], int n, int g, int *cnt) { int i, v, j; for (i = g; i < n; i++) { v = R[i]; j = i - g; while (j >= 0 && R[j] > v) { R[j + g] = R[j]; j = j - g; (*cnt)++; //()をつける!! ...
[["+", 51, 2, 3, 4, 0, 16, 31, 16, 12, 13], ["+", 12, 74, 51, 2, 3, 4, 0, 16, 17, 48], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
461
9
#include <math.h> #include <stdio.h> #include <stdlib.h> int insertion_sort(int, int[], int, int); int shellSort(int, int[]); void printArray(int[], int); int main(int argc, char **argv) { int size; scanf("%d\n", &size); int array[size]; for (int i = 0; i < size; i++) scanf("%d", &array[i]); int count =...
#include <math.h> #include <stdio.h> #include <stdlib.h> int insertion_sort(int, int[], int, int); int shellSort(int, int[]); void printArray(int[], int); int main(int argc, char **argv) { int size; scanf("%d\n", &size); int array[size]; for (int i = 0; i < size; i++) scanf("%d", &array[i]); int count =...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 57, 15, 23, 0, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 20], ["-", 64, 9, 0, 57, 15, 23, 0, 16, 17, 60], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 17, 33], ["-", 0, 57...
0
471
10
#include <cmath> #include <iostream> #include <vector> using namespace std; int main() { int n, cnt; vector<int> nums; auto insertionSort = [&nums, &n, &cnt](int d) { for (int i = d; i < n; ++i) { int top = nums[i]; int j; for (j = i - d; i >= 0 && nums[j] > top; j -= d) { nums[j + ...
#include <cmath> #include <iostream> #include <vector> using namespace std; int main() { int n, cnt; vector<int> nums; auto insertionSort = [&nums, &n, &cnt](int d) { for (int i = d; i < n; ++i) { int top = nums[i]; int j; for (j = i - d; j >= 0 && nums[j] > top; j -= d) { nums[j + ...
[["-", 8, 9, 0, 7, 15, 16, 31, 16, 31, 22], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 31, 22]]
1
282
2
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <vector> using namespace std; long long cnt; int l; int A[1000000]; int n; vector<int> G; void insertionsort(int A[], int n, int g) { for (int i = g; i < n; i++) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) {...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <vector> using namespace std; long long cnt; int l; int A[1000000]; int n; vector<int> G; void insertionSort(int A[], int n, int g) { for (int i = g; i < n; i++) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) {...
[["-", 36, 36, 0, 30, 0, 14, 49, 53, 49, 22], ["+", 36, 36, 0, 30, 0, 14, 49, 53, 49, 22], ["-", 0, 11, 31, 69, 341, 342, 0, 11, 17, 32], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 7, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 14, 8, 9...
1
357
10
var stdin = require('fs').readFileSync('/dev/stdin', 'utf8'); var operands = stdin.split(' '); var stack = []; operands.forEach(function(operand) { if (operand === '+') { stack.push(parseInt(stack.pop(), 10) + parseInt(stack.pop(), 10)); } else if (operand === '-') { var n2 = parseInt(stack.pop(), 10); ...
var stdin = require('fs').readFileSync('/dev/stdin', 'utf8'); var operands = stdin.trim().split(' '); var stack = []; operands.forEach(function(operand) { if (operand === '+') { stack.push(parseInt(stack.pop(), 10) + parseInt(stack.pop(), 10)); } else if (operand === '-') { var n2 = parseInt(stack.pop(), 10...
[["+", 51, 2, 63, 558, 500, 2, 63, 558, 559, 560], ["+", 51, 2, 63, 558, 500, 2, 3, 3, 0, 24], ["+", 51, 2, 63, 558, 500, 2, 3, 3, 0, 25], ["+", 0, 198, 0, 200, 51, 2, 63, 558, 0, 131]]
2
199
4
var input = require('fs') .readFileSync('/dev/stdin', 'utf8') .trim() .split(' ') .map(function(value) { if (!isNaN(parseInt(value))) { return parseInt(value); } else { return valu...
var input = require('fs') .readFileSync('/dev/stdin', 'utf8') .trim() .split(' ') .map(function(value) { if (!isNaN(parseInt(value))) { return parseInt(value); } else { return valu...
[["-", 0, 435, 8, 556, 0, 198, 0, 200, 141, 22], ["+", 0, 435, 8, 556, 0, 198, 0, 200, 141, 22]]
2
311
4
<?php $stack=[]; $top=0; $data=explode(' ',trim(fgets(STDIN))); foreach($data as $d) { if($d=='+'){ $stack[$top-1]+=$stack[$top--]; } elseif($d=='-'){ $stack[$top-1]-=$stack[$top--]; }elseif($d=='*'){ $stack[$top-1]*=$stack[$top--]; }else{ $stack[++$top]=$d; } } echo stack[1].PHP_EOL;
<?php $stack=[]; $top=0; $data=explode(' ',trim(fgets(STDIN))); foreach($data as $d) { if($d=='+'){ $stack[$top-1]+=$stack[$top--]; } elseif($d=='-'){ $stack[$top-1]-=$stack[$top--]; }elseif($d=='*'){ $stack[$top-1]*=$stack[$top--]; }else{ $stack[++$top]=$d; } } echo $stack[1].PHP_EOL;
[["+", 0, 608, 0, 16, 31, 69, 0, 606, 0, 607]]
6
146
1
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Stack; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] S = br.readLine().split("\\s"...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Stack; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] S = br.readLine().split("\\s"...
[["-", 0, 1, 0, 492, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 492, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 12, 22]]
3
256
4
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String a = "0"; IntStack iStack = new IntStack(); while (sc.hasNext()) { String str = sc.next(); if (str.equals("+")) { int x = iStack.pop(); int y = iStac...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String a = "0"; IntStack iStack = new IntStack(); while (sc.hasNext()) { String str = sc.next(); if (str.equals("+")) { int x = iStack.pop(); int y = iStac...
[["-", 0, 1, 0, 492, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 492, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 12, 22]]
3
332
4
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Stack; public class Main { public static void main(String[] args) throws IOException { // TODO ????????????????????????????????????????????? BufferedReader br = new BufferedReader(new InputStreamRea...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Stack; public class Main { public static void main(String[] args) throws IOException { // TODO ????????????????????????????????????????????? BufferedReader br = new BufferedReader(new InputStreamRea...
[["-", 0, 1, 0, 492, 3, 4, 0, 492, 500, 22], ["+", 0, 1, 0, 492, 3, 4, 0, 492, 500, 22], ["-", 0, 1, 0, 492, 3, 4, 0, 492, 141, 22], ["+", 0, 1, 0, 492, 3, 4, 0, 492, 141, 22], ["-", 0, 492, 3, 4, 0, 492, 3, 4, 0, 22], ["-", 0, 492, 3, 4, 0, 492, 3, 4, 0, 21], ["-", 0, 492, 3, 4, 0, 492, 3, 4, 0, 499], ["+", 3, 4, 0, 4...
3
250
11
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); List<String> porand = new ArrayList<>(Arrays.asList(sc.nextLine().split(" "))); sc.close(); ...
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); List<String> porand = new ArrayList<>(Arrays.asList(sc.nextLine().split(" "))); sc.close(); ...
[["-", 8, 196, 0, 503, 49, 200, 51, 5, 0, 491], ["+", 8, 196, 0, 503, 49, 200, 51, 5, 0, 491]]
3
366
2
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); String[] str = sc.nextLine().split(" "); int[] num = new int[str.length]; int i = 0; for (int j = 0; j < str.length; j++) { String temp = str[j]; ...
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); String[] str = sc.nextLine().split(" "); int[] num = new int[str.length]; int i = 0; for (int j = 0; j < str.length; j++) { String temp = str[j]; ...
[["-", 15, 15, 0, 492, 3, 4, 0, 5, 0, 491], ["+", 15, 15, 0, 492, 3, 4, 0, 5, 0, 491]]
3
243
2
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static int top = 0; public static List<Integer> stack = new ArrayList<Integer>(); public static void push(int x) { stack.add(x); top++; } public static int pop() { top--; return stack.r...
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static int top = 0; public static List<Integer> stack = new ArrayList<Integer>(); public static void push(int x) { stack.add(x); top++; } public static int pop() { top--; return stack....
[["-", 15, 15, 0, 492, 3, 4, 0, 5, 0, 491], ["+", 15, 15, 0, 492, 3, 4, 0, 5, 0, 491]]
3
251
2
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int[] stack = new int[100]; int stackPointer = 0; String s; while (scan.hasNext()) { s = scan.next(); if (s.equals("+")) { stack[stackPointer - 2] = ...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int[] stack = new int[100]; int stackPointer = 0; String s; while (scan.hasNext()) { s = scan.next(); if (s.equals("+")) { stack[stackPointer - 2] = ...
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 499], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 499], ["-", 75, 57, 64, 196, 0, 1, 0, 11, 12, 499], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 12, 499]]
3
222
6
#include <stdio.h> int cnt, m, G[101]; int insertionSort(int *A, int n, int g) { int i; for (i = g; i < n; i++) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j = j - g; cnt++; } A[j + g] = v; } } void shellSort(int *A, int n) { cnt = 0; in...
#include <stdio.h> int cnt, m, G[101]; int insertionSort(int *A, int n, int g) { int i; for (i = g; i < n; i++) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j = j - g; cnt++; } A[j + g] = v; } } void shellSort(int *A, int n) { cnt = 0; in...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
339
1
#include <stdio.h> long long cnt; int G[100]; int m; void insertionSort(int A[], int n, int g) { int v, i, j; for (i = g; i < n; i++) { v = A[i]; j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j = j - g; cnt++; } A[j + g] = v; } } void print(int m, int G[], int A...
#include <stdio.h> long long cnt; int G[100]; int m; void insertionSort(int A[], int n, int g) { int v, i, j; for (i = g; i < n; i++) { v = A[i]; j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j = j - g; cnt++; } A[j + g] = v; } } void print(int m, int G[], int A...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
432
4
#include <iostream> #include <vector> using namespace std; int n, *d; int cnt = 0; void sort(int length) { for (int i = 0; i < length; i++) { for (int k = i + length; k < n; k += length) { int now = d[k]; int m = k - length; for (; m >= 0; m -= length) { d[m + length] = d[m]; i...
#include <iostream> #include <vector> using namespace std; int n, *d; int cnt = 0; void sort(int length) { for (int i = 0; i < length; i++) { for (int k = i + length; k < n; k += length) { int now = d[k]; int m = k - length; for (; m >= 0; m -= length) { d[m + length] = d[m]; i...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
314
4
#include <algorithm> #include <climits> #include <cstring> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; void insertionSort(vector<int> &A, int n, int g, int &cnt) { for (int i = g; i < n; ++i) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) { ...
#include <algorithm> #include <climits> #include <cstring> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; void insertionSort(vector<int> &A, int n, int g, int &cnt) { for (int i = g; i < n; ++i) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) { ...
[["+", 8, 9, 0, 7, 15, 16, 31, 23, 0, 24], ["+", 0, 7, 15, 16, 31, 23, 0, 16, 17, 67], ["+", 15, 16, 31, 23, 0, 16, 12, 16, 31, 22], ["+", 15, 16, 31, 23, 0, 16, 12, 16, 17, 18], ["+", 15, 16, 31, 23, 0, 16, 12, 16, 12, 22], ["+", 8, 9, 0, 7, 15, 16, 31, 23, 0, 25]]
1
342
6
#include <algorithm> #include <iostream> using namespace std; int cnt = 0; int G[] = {1, 4, 13, 40, 121, 364, 1093, 3280, 9841, 29524, 88573, 265720, 797161}; int A[1000000]; int shellSort(int A[], int n); void insertionSort(int A[], int n, int g); int main() { ios::sync_with_stdio(false...
#include <algorithm> #include <iostream> using namespace std; int cnt = 0; int G[] = {1, 4, 13, 40, 121, 364, 1093, 3280, 9841, 29524, 88573, 265720, 797161}; int A[1000000]; int shellSort(int A[], int n); void insertionSort(int A[], int n, int g); int main() { ios::sync_with_stdio(false...
[["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 85], ["-", 0, 52, 15, 339, 51, 16, 12, 16, 12, 13]]
1
366
2
#include <iostream> using namespace std; int x[10000000]; int G[20]; int v; int w; int cnt = 0; int m; int n; void sort1(int x[], int n, int g) { for (int i = g; i < n; i++) { v = x[i]; w = i - g; while (w >= 0 && x[w] > v) { x[w + g] = x[w]; w = w - g; cnt++; } x[w + g] = v; ...
#include <iostream> using namespace std; int x[10000000]; int G[20]; int v; int w; int cnt = 0; int m; int n; void sort1(int x[], int n, int g) { for (int i = g; i < n; i++) { v = x[i]; w = i - g; while (w >= 0 && x[w] > v) { x[w + g] = x[w]; w = w - g; cnt++; } x[w + g] = v; ...
[["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 73], ["-", 0, 14, 8, 9, 0, 7, 26, 27, 17, 29], ["+", 0, 14, 8, 9, 0, 7, 26, 27, 17, 68]]
1
344
5
#include <cstdio> #include <iostream> using namespace std; int x[10000000]; int G[20]; int v; int w; int cnt = 0; int m; int n; void sort1(int x[], int n, int g) { for (int i = g; i < n; i++) { v = x[i]; w = i - g; while (w >= 0 && x[w] > v) { x[w + g] = x[w]; w = w - g; cnt++; } ...
#include <cstdio> #include <iostream> using namespace std; int x[10000000]; int G[20]; int v; int w; int cnt = 0; int m; int n; void sort1(int x[], int n, int g) { for (int i = g; i < n; i++) { v = x[i]; w = i - g; while (w >= 0 && x[w] > v) { x[w + g] = x[w]; w = w - g; cnt++; } ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
358
1
#include <iostream> using namespace std; int cnt; void insertionSort(int *a, int n, int g) { int i, j, v; for (i = g; i < n; i++) { v = a[i]; j = i - g; while ((j >= 0) && (a[j] > v)) { a[j + g] = a[j]; j = j - g; cnt++; }; a[j + g] = v; } } void shellsort(int *a, int n)...
#include <iostream> using namespace std; int cnt; void insertionSort(int *a, int n, int g) { int i, j, v; for (i = g; i < n; i++) { v = a[i]; j = i - g; while ((j >= 0) && (a[j] > v)) { a[j + g] = a[j]; j = j - g; cnt++; }; a[j + g] = v; } } void shellsort(int *a, int n)...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 31, 69, 341, 342, 0, 16, 31, 16, 31, 22], ["+", 31, 69, 341, 342, 0, 16, 31, 16, 17, 33], ["+", 31, 69, 341, 342, 0, 16, 31, 16, 12, 13], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 17, 33]]
1
380
8
#include <cstdio> #include <vector> using namespace std; int insSort(vector<int> &arr, int g) { int v, cnt; cnt = 0; for (int i = g; i < arr.size(); ++i) { int j; v = arr[i]; for (j = i - g; j >= 0 && arr[j] > v; j -= g) { arr[j + g] = arr[j]; ++cnt; } arr[j + g] = v; } retur...
#include <cstdio> #include <vector> using namespace std; int insSort(vector<int> &arr, int g) { int v, cnt; cnt = 0; for (int i = g; i < arr.size(); ++i) { int j; v = arr[i]; for (j = i - g; j >= 0 && arr[j] > v; j -= g) { arr[j + g] = arr[j]; ++cnt; } arr[j + g] = v; } retur...
[["-", 3, 4, 0, 69, 341, 342, 0, 16, 31, 22], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 13]]
1
373
4
#include "bits/stdc++.h" using namespace std; long long cnt; int l; int A[1000000]; int n; vector<int> G; void insertionSort(int A[], int n, int g) { for (int i = g; i < n; ++i) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j -= g; cnt++; } A[j + g...
#include "bits/stdc++.h" using namespace std; long long cnt; int l; int A[1000000]; int n; vector<int> G; void insertionSort(int A[], int n, int g) { for (int i = g; i < n; ++i) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j -= g; cnt++; } A[j + g...
[["-", 0, 14, 8, 9, 0, 7, 26, 27, 17, 29], ["+", 0, 14, 8, 9, 0, 7, 26, 27, 17, 68]]
1
355
2
#include <algorithm> #include <stdio.h> int m = 0; int count = 0; int G[1000000]; void trace(int a[], int size) { for (int i = 0; i < size; ++i) { if (i > 0) { printf(" "); } printf("%d", a[i]); } printf("\n"); } void InsertionSort(int A[], int N, int g) { for (int i = g; i < N; ++i) { ...
#include <algorithm> #include <stdio.h> int m = 0; int count = 0; int G[1000000]; void trace(int a[], int size) { for (int i = 0; i < size; ++i) { if (i > 0) { printf(" "); } printf("%d", a[i]); } printf("\n"); } void InsertionSort(int A[], int N, int g) { for (int i = g; i < N; ++i) { ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24]]
1
413
7
/************** * Shell Sort *************/ #include <algorithm> #include <cstdio> #include <vector> //??£?¨? using namespace std; typedef vector<int> TList; //?????????????????? void insertionSort(TList &A, int g, int &cnt) { for (unsigned int i = g; i < (A.size()); i++) { int v = A[i]; int j = i - g; ...
/************** * Shell Sort *************/ #include <algorithm> #include <cstdio> #include <vector> //??£?¨? using namespace std; typedef vector<int> TList; //?????????????????? void insertionSort(TList &A, int g, int &cnt) { for (unsigned int i = g; i < (A.size()); i++) { int v = A[i]; int j = i - g; ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
440
2
#include <cstdio> #include <iostream> #include <vector> using namespace std; int a[1000000]; int cnt = 0; void insertionsort(int A[], int n, int g) { for (int i = g; i < n; ++i) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] >= v) { A[j + g] = A[j]; j = j - g; cnt++; } A[j ...
#include <cstdio> #include <iostream> #include <vector> using namespace std; int a[1000000]; int cnt = 0; void insertionsort(int A[], int n, int g) { for (int i = g; i < n; ++i) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j = j - g; cnt++; } A[j +...
[["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 20], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 47]]
1
354
2
#include <algorithm> #include <cstdio> using namespace std; int A[1000000]; int G[1000000 / 2]; int cnt; void print(int A[], int n) { for (int i = 0; i < n; i++) { printf("%d\n", A[i]); } } void insertionSort(int A[], int n, int g) { for (int i = g; i < n; i++) { int v = A[i]; int j = i - g; w...
#include <algorithm> #include <cstdio> using namespace std; int A[1000000]; int G[1000000 / 2]; int cnt; void print(int A[], int n) { for (int i = 0; i < n; i++) { printf("%d\n", A[i]); } } void insertionSort(int A[], int n, int g) { for (int i = g; i < n; i++) { int v = A[i]; int j = i - g; w...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19], ["-", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 27, 17, 29], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
382
5
#include <algorithm> #include <iostream> #include <new> #include <vector> using namespace std; int cnt; int m; vector<int> v; void insertionSort(int A[], int n, int g) { int i, j, tmp; for (i = g; i < n; i++) { tmp = A[i]; j = i - g; while (j >= 0 && A[j] > tmp) { A[j + g] = A[j]; j = j - ...
#include <algorithm> #include <iostream> #include <new> #include <vector> using namespace std; int cnt; int m; vector<int> v; void insertionSort(int A[], int n, int g) { int i, j, tmp; for (i = g; i < n; i++) { tmp = A[i]; j = i - g; while (j >= 0 && A[j] > tmp) { A[j + g] = A[j]; j = j - ...
[["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22]]
1
320
4
#include <stdio.h> #include <vector> using namespace std; vector<int> G; int cnt = 0; void insertionSort(int *p, int n, int g) { for (int i = g; i < n; i++) { int v = p[i]; int j = i - g; while (j >= 0 && p[j] > v) { p[j + g] = p[j]; j -= g; cnt = cnt + 1; } p[j + g] = v; } } ...
#include <stdio.h> #include <vector> using namespace std; vector<int> G; int cnt = 0; void insertionSort(int *p, int n, int g) { for (int i = g; i < n; i++) { int v = p[i]; int j = i - g; while (j >= 0 && p[j] > v) { p[j + g] = p[j]; j -= g; cnt = cnt + 1; } p[j + g] = v; } }...
[["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 33], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
353
5
#include <bits/stdc++.h> #define REP(i, s, n) for (int i = s; i < n; i++) #define rep(i, n) REP(i, 0, n) #define MAX 1000010 using namespace std; int n, A[MAX], cnt; void insertionSort(int g) { REP(i, g, n) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j = j ...
#include <bits/stdc++.h> #define REP(i, s, n) for (int i = s; i < n; i++) #define rep(i, n) REP(i, 0, n) #define MAX 1000010 using namespace std; int n, A[MAX], cnt; void insertionSort(int g) { REP(i, g, n) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j = j ...
[["+", 51, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["+", 51, 16, 31, 16, 31, 16, 31, 16, 12, 13], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 17, 72], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 12, 13]]
1
308
4
/* * ALDS1_2_D.cpp * * Created on: Apr 25, 2018 * Author: 13743 */ #include <iostream> using namespace std; int cnt = 0; void insertionSort(int *a, int n, int g) { for (int i = g; i < n; i++) { int v = a[i]; int j = i - g; while (j >= 0 && a[j] > v) { a[j + g] = a[j]; j = j - g;...
/* * ALDS1_2_D.cpp * * Created on: Apr 25, 2018 * Author: 13743 */ #include <iostream> using namespace std; int cnt = 0; void insertionSort(int *a, int n, int g) { for (int i = g; i < n; i++) { int v = a[i]; int j = i - g; while (j >= 0 && a[j] > v) { a[j + g] = a[j]; j = j - g;...
[["-", 0, 69, 341, 342, 0, 16, 31, 16, 31, 22], ["+", 0, 69, 341, 342, 0, 16, 31, 16, 31, 22], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 12, 69, 341, 342, 0, 16, 31, 16, 31, 22],...
1
304
8
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int j = 0; int stac[99]; char str[16]; while (scanf("%s", str) != EOF) { switch (*str) { case '+': j--; stac[j - 1] += stac[j]; break; case '-': j--; stac[j - 1] - +stac[j]; break; ca...
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int j = 0; int stac[99]; char str[16]; while (scanf("%s", str) != EOF) { switch (*str) { case '+': j--; stac[j - 1] += stac[j]; break; case '-': j--; stac[j - 1] -= stac[j]; break; ca...
[["-", 8, 9, 0, 100, 0, 1, 0, 16, 17, 33], ["-", 0, 100, 0, 1, 0, 16, 12, 91, 17, 72], ["+", 8, 9, 0, 100, 0, 1, 0, 11, 17, 110], ["-", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22]]
0
153
5
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int x, y; char s[100]; int stack[100]; int n = 0; while (scanf("%s", s) != EOF) { if (s[0] == '+') { x = stack[--n]; y = stack[--n]; stack[n++] = x + y; } else if (s[0] == '-') { x = stack[--n]; y =...
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int x, y; char s[100]; int stack[100]; int n = 0; while (scanf("%s", s) != EOF) { if (s[0] == '+') { x = stack[--n]; y = stack[--n]; stack[n++] = x + y; } else if (s[0] == '-') { x = stack[--n]; y =...
[["+", 0, 2, 3, 4, 0, 69, 71, 27, 17, 68]]
0
204
1
#include <stdio.h> #include <stdlib.h> void push(int); int pop(void); int stack[100]; int stacksum = 0; int main(void) { int i, x, y, data1; char data[100]; for (i = 0; scanf("%s", data) != EOF; i++) { if (data[0] == '+') { x = pop(); y = pop(); push(x + y); } else if (data[0] == '-'...
#include <stdio.h> #include <stdlib.h> void push(int); int pop(void); int stack[100]; int stacksum = 0; int main(void) { int i, x, y, data1; char data[100]; for (i = 0; scanf("%s", data) != EOF; i++) { if (data[0] == '+') { x = pop(); y = pop(); push(x + y); } else if (data[0] == '-'...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
0
234
4
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 100 int main() { int x = 0, y = 0, i = 0; char s[MAX]; int sgym[MAX]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { i--; sgym[i - 1] += sgym[i]; } else if (s[0] == '-') { i--; sgym[i - 1] -= sgym[i]; ...
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 100 int main() { int x = 0, y = 0, i = 0; char s[MAX]; int sgym[MAX]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { i--; sgym[i - 1] += sgym[i]; } else if (s[0] == '-') { i--; sgym[i - 1] -= sgym[i]; ...
[["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 68], ["+", 75, 76, 0, 57, 64, 9, 0, 1, 0, 35]]
0
170
3
#include <stdio.h> #include <stdlib.h> #include <string.h> main() { int x; int i = 0; int n[100]; char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { n[i - 2] = n[i - 1] + n[i - 2]; i = i + 1; } else if (s[0] == '-') { n[i - 2] = n[i - 2] - n[i - 1]; i = i + 1; ...
#include <stdio.h> #include <stdlib.h> #include <string.h> main() { int x; int i = 0; int n[100]; char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { n[i - 2] = n[i - 1] + n[i - 2]; i = i - 1; } else if (s[0] == '-') { n[i - 2] = n[i - 2] - n[i - 1]; i = i - 1; ...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33]]
0
206
6
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int num[100]; int i = 0; char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { num[i - 2] += num[i - 1]; i = i - 2; } else if (s[0] == '-') { num[i - 2] -= num[i - 1]; i = i - 2; } else if (s[...
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int num[100]; int i = 0; char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { num[i - 2] += num[i - 1]; i = i - 1; } else if (s[0] == '-') { num[i - 2] -= num[i - 1]; i = i - 1; } else if (s[...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
0
180
6
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 200 int sp = MAX; int stack[MAX]; void push(int n) { if (sp > 0) { stack[--sp] = n; } else { fprintf(stderr, "push overflow\n"); } } int pop() { if (sp < MAX) { return stack[sp++]; } else { return 0; } } int main(void...
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 200 int sp = MAX; int stack[MAX]; static void push(int n) { if (sp > 0) { stack[--sp] = n; } else { fprintf(stderr, "push overflow\n"); } } static int pop() { if (sp < MAX) { return stack[sp++]; } else { return 0; } } ...
[["+", 36, 36, 0, 30, 0, 14, 0, 114, 0, 115], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["-", 75, 76, 0, 57, 15, 23, 0, 11, 17, 32], ["+", 75, 76, 0, 57, 15, 23, 0, 16, 17, 60]]
0
229
5
#include <stdio.h> #include <stdlib.h> int pop(); void push(int); int stack[2000]; int kazu = 0; void push(int j) { stack[kazu++] = j; } int pop() { if (kazu <= 0) return 0; return stack[--kazu]; } int main() { int i, j, k = 0, l, n, Ans; char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+')...
#include <stdio.h> #include <stdlib.h> int pop(); void push(int); int stack[2000]; int kazu = 0; void push(int j) { stack[kazu++] = j; } int pop() { if (kazu <= 0) return 0; return stack[--kazu]; } int main() { int i, j, k = 0, l, n, Ans; char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+')...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
0
250
4
#include <stdio.h> int top; int S[1000]; // stack!! void init() { top = 0; } void push(int x) { top++; S[top] = x; } int pop() { top--; return S[top + 1]; } int main() { char s[100]; int a, b; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = pop(); b = pop(); push(a + b); ...
#include <stdio.h> int top; int S[1000]; // stack!! void init() { top = 0; } void push(int x) { top++; S[top] = x; } int pop() { top--; return S[top + 1]; } int main() { char s[100]; int a, b; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = pop(); b = pop(); push(a + b); ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
0
213
4
#include <stdio.h> #include <stdlib.h> int a[1000], top; void push(int n) { a[top++] = n; } int pop() { return a[top--]; } int main() { char ch[100]; int n1, n2; top = 0; while (scanf("%s", ch) != EOF) { if (ch[0] == '+') { n1 = pop(); n2 = pop(); push(n1 + n2); } else if (ch[0] =...
#include <stdio.h> #include <stdlib.h> int a[1000], top; void push(int n) { a[top++] = n; } int pop() { return a[--top]; } int main() { char ch[100]; int n1, n2; top = 0; while (scanf("%s", ch) != EOF) { if (ch[0] == '+') { n1 = pop(); n2 = pop(); push(n1 + n2); } else if (ch[0] =...
[["-", 8, 9, 0, 37, 0, 69, 71, 27, 28, 22], ["+", 8, 9, 0, 37, 0, 69, 71, 27, 28, 22]]
0
201
8
#include <stdio.h> #include <stdlib.h> static int stack[100]; static int top = 0; void push(int v) { stack[++top] = v; } int pop(void) { return stack[top--]; } int main(void) { int a, b; char input[100]; while (scanf("%s", input) != EOF) { switch (input[0]) { case '+': a = pop(); b = pop(...
#include <stdio.h> #include <stdlib.h> static int stack[100]; static int top = 0; void push(int v) { stack[++top] = v; } int pop(void) { return stack[top--]; } int main(void) { int a, b; char input[100]; while (scanf("%s", input) != EOF) { switch (input[0]) { case '+': b = pop(); a = pop(...
[["-", 8, 9, 0, 100, 0, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 100, 0, 1, 0, 11, 31, 22]]
0
200
12
#include <stdio.h> #include <stdlib.h> int main() { char s[16]; int S[100], p = 0; while (scanf("%s ", s) != EOF) { int a, b; if (*s > '0') S[p++] = atoi(s); else { a = S[--p]; b = S[--p]; if (*s == '*') S[p++] = b * a; else if (*s == '+') S[p++] = b + a; ...
#include <stdio.h> #include <stdlib.h> int main() { char s[16]; int S[100], p = 0; while (scanf("%s ", s) != EOF) { int a, b; if (*s > '/') S[p++] = atoi(s); else { a = S[--p]; b = S[--p]; if (*s == '*') S[p++] = b * a; else if (*s == '+') S[p++] = b + a; ...
[["-", 0, 57, 15, 23, 0, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 23, 0, 16, 12, 103, 0, 125]]
0
161
2
#include <stdio.h> #include <stdlib.h> int main() { char data[6]; int stack[128]; int k = 0; while (fscanf("%s", data) != EOF) { if (data[0] == '+') { k--; stack[k - 1] = stack[k - 1] + stack[k]; } else if (data[0] == '-') { k--; stack[k - 1] = stack[k - 1] - stack[k]; } else...
#include <stdio.h> #include <stdlib.h> int main() { char data[6]; int stack[128]; int k = 0; while (scanf("%s", data) != EOF) { if (data[0] == '+') { k--; stack[k - 1] = stack[k - 1] + stack[k]; } else if (data[0] == '-') { k--; stack[k - 1] = stack[k - 1] - stack[k]; } else ...
[["-", 0, 52, 15, 23, 0, 16, 31, 2, 63, 22], ["+", 0, 52, 15, 23, 0, 16, 31, 2, 63, 22]]
0
181
2
/* * Stack.c * * Created on: 2015/02/14 */ #include <stdio.h> #include <stdlib.h> #include <string.h> int stack[100]; int count = 0; int pop() { count--; return stack[count]; } void push(int n) { stack[count] = n; count++; } int main(void) { int x, n, m; char s[100]; while (scanf("%s", s) != EOF...
/* * Stack.c * * Created on: 2015/02/14 */ #include <stdio.h> #include <stdlib.h> #include <string.h> int stack[100]; int count = 0; int pop() { count--; return stack[count]; } void push(int n) { stack[count] = n; count++; } int main(void) { int x, n, m; char s[100]; while (scanf("%s", s) != EOF...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
0
217
4
#include <stdio.h> int computeRPN(int *stack, int n, int opt) { int res; res = 0; if ('+' == opt) { res = stack[n - 1] + stack[n]; } else if ('-' == opt) { res = stack[n - 1] - stack[n]; } else if ('*' == opt) { res = stack[n - 1] * stack[n]; } else if ('/' == opt) { res = stack[n - 1] / s...
#include <stdio.h> int computeRPN(int *stack, int n, int opt) { int res; res = 0; if ('+' == opt) { res = stack[n - 1] + stack[n]; } else if ('-' == opt) { res = stack[n - 1] - stack[n]; } else if ('*' == opt) { res = stack[n - 1] * stack[n]; } else if ('/' == opt) { res = stack[n - 1] / s...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]]
0
293
2
#include <stdio.h> #include <stdlib.h> #define MAX 100 int top; void push(int); int pop(void); int S[MAX]; int a, b, sum; int main() { char inputc[100]; int inputi, i = 0; while (1) { if (scanf("%c", inputc) == EOF) break; if (inputc[0] != ' ') { if (inputc[0] == '+') { a = pop(); ...
#include <stdio.h> #include <stdlib.h> #define MAX 100 int top; void push(int); int pop(void); int S[MAX]; int a, b, sum; int main() { char inputc[100]; int inputi, i = 0; while (1) { if (scanf("%s", inputc) == EOF) break; if (inputc[0] != ' ') { if (inputc[0] == '+') { a = pop(); ...
[["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6]]
0
265
2
#include <stdio.h> #include <stdlib.h> void initialize(void); int isEmpty(void); int isFull(void); void push(int); int pop(void); int MAX = 100; int operand[100]; int top; int main() { char x2; char *x1; int p1, p2; int s; initialize(); x1 = &x2; while (1) { if (scanf(" %c", x1) == EOF) break...
#include <stdio.h> #include <stdlib.h> void initialize(void); int isEmpty(void); int isFull(void); void push(int); int pop(void); int MAX = 110; int operand[110]; int top; int main() { char x2; char *x1; int p1, p2; int s; initialize(); x1 = &x2; while (1) { if (scanf(" %s", x1) == EOF) break...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6]]
0
330
6
#include <stdio.h> #include <string.h> #define MAX 100 void initialize(void); void push(int); int pop(void); int isEmpty(void); int isFull(void); int stack[MAX]; int top; main() { char *s; int x, y; initialize(); while (scanf("%s", s) != EOF) { if (s[0] == '+') { x = pop(); y = pop(); ...
#include <stdio.h> #include <string.h> #define MAX 101 void initialize(void); void push(int); int pop(void); int isEmpty(void); int isFull(void); int stack[MAX]; int top; main() { char s[MAX]; int x, y; initialize(); while (scanf("%s", s) != EOF) { if (s[0] == '+') { x = pop(); y = pop(); ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 30, 0, 9, 0, 43, 49, 84, 0, 48], ["+", 0, 30, 0, 9, 0, 43, 49, 80, 0, 70], ["+", 0, 30, 0, 9, 0, 43, 49, 80, 81, 22], ["+", 0, 30, 0, 9, 0, 43, 49, 80, 0, 73]]
0
331
6
#include <stdio.h> #include <stdlib.h> #define MAX 100 main() { int S[MAX], i = 0, x, a; char input[MAX]; while (scanf("%s", input) != '\n') { if (input[0] == '+') { S[i - 2] = S[i - 1] + S[i - 2]; i--; } else if (input[0] == '-') { S[i - 2] = S[i - 2] - S[i - 1]; i--; } else...
#include <stdio.h> #include <stdlib.h> #define MAX 100 main() { int S[MAX], i = 0, x, a; char input[MAX]; while (scanf("%s", input) != EOF) { if (input[0] == '+') { S[i - 2] = S[i - 1] + S[i - 2]; i--; } else if (input[0] == '-') { S[i - 2] = S[i - 2] - S[i - 1]; i--; } else ...
[["-", 0, 52, 15, 23, 0, 16, 12, 103, 0, 104], ["-", 0, 52, 15, 23, 0, 16, 12, 103, 0, 44], ["+", 0, 9, 0, 52, 15, 23, 0, 16, 12, 22]]
0
201
4
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 1000 int top, S[MAX]; int pop(void); void push(int); int main() { int a, b; char s[MAX]; top = 0; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = pop(); b = pop(); push(a + b); } else if (s[0] == '-') {...
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 1000 int top, S[MAX]; int pop(void); void push(int); int main() { int a, b; char s[MAX]; top = 0; while (scanf("%s", s) != EOF) { if (s[0] == '+') { a = pop(); b = pop(); push(a + b); } else if (s[0] == '-') {...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
0
220
4
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 1000 int stock[MAX] = {0}; int top; void push(int x) { stock[++top] = x; } int pop() { top--; return stock[top + 1]; } int main() { int a, b; top = 0; char sam[MAX]; while (scanf("%s", sam) != EOF) { if (sam[0] == '+') { ...
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 1000 int stock[MAX] = {0}; int top; void push(int x) { stock[++top] = x; } int pop() { top--; return stock[top + 1]; } int main() { int a, b; top = 0; char sam[100]; while (scanf("%s", sam) != EOF) { if (sam[0] == '+') { ...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
0
215
6
#include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> typedef struct stack_tag stack_t; struct stack_tag { int32_t *data; size_t max_len; size_t size; }; static bool check_is_null(const void *const p) { if (p == NULL) { return true; } return false; } stack_t *stack_create(...
#include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> typedef struct stack_tag stack_t; struct stack_tag { int32_t *data; size_t max_len; size_t size; }; static bool check_is_null(const void *const p) { if (p == NULL) { return true; } return false; } stack_t *stack_create(...
[["-", 0, 57, 64, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 49, 22]]
0
645
12
#include <stdio.h> #include <stdlib.h> #define MAX_N 200 int top, a[MAX_N]; void push(int x) { a[top + 1] = x; top++; } int pop(void) { int tmp = a[top]; a[top] = 0; top--; return tmp; } int main(void) { char c[100]; top = 0; while (scanf("%s", c) != EOF) { int a, b; if (c[0] == '+') { ...
#include <stdio.h> #include <stdlib.h> #define MAX_N 200 int top, a[MAX_N]; void push(int x) { a[top + 1] = x; top++; } int pop(void) { int tmp = a[top]; a[top] = 0; top--; return tmp; } int main(void) { char c[100]; top = 0; while (scanf("%s", c) != EOF) { int a, b; if (c[0] == '+') { ...
[["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
0
220
2
#include <stdio.h> #include <stdlib.h> #include <string.h> int top, S[100]; void push(int a) { S[++top] = a; } int pop() { int ans; top--; ans = S[top + 1]; return ans; } int main() { int s, t, u; top = 0; char array[1000000]; while (1) { if (scanf("%s", &array[0]) == EOF) break; if...
#include <stdio.h> #include <stdlib.h> #include <string.h> int top, S[100]; void push(int a) { S[++top] = a; } int pop() { int ans; top--; ans = S[top + 1]; return ans; } int main() { int s, t, u; top = 0; char array[1000000]; while (1) { if (scanf("%s", &array[0]) == EOF) break; if...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
0
230
4
#include <stdio.h> #include <stdlib.h> #include <string.h> void push(int); int pop(void); int S[100]; int top = 0; int main() { int x; char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { push(pop() + pop()); break; } else if (s[0] == '-') { x = pop(); push(pop() - x)...
#include <stdio.h> #include <stdlib.h> #include <string.h> void push(int); int pop(void); int S[100]; int top = 0; int main() { int x; char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { push(pop() + pop()); } else if (s[0] == '-') { x = pop(); push(pop() - x); } e...
[["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35], ["-", 75, 76, 0, 57, 64, 9, 0, 1, 0, 35], ["-", 75, 76, 0, 57, 64, 9, 0, 93, 0, 94]]
0
208
6
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int i = 0; int x[100]; char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { x[i - 2] = x[i - 2] + x[i - 1]; i--; } else if (s[0] == '-') { x[i - 2] = x[i - 2] - x[i - 2]; i--; } else if (s[0]...
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int i = 0; int x[100]; char s[100]; while (scanf("%s", s) != EOF) { if (s[0] == '+') { x[i - 2] = x[i - 2] + x[i - 1]; i--; } else if (s[0] == '-') { x[i - 2] = x[i - 2] - x[i - 1]; i--; } else if (s[0]...
[["-", 0, 11, 12, 16, 12, 69, 71, 16, 12, 13], ["+", 0, 11, 12, 16, 12, 69, 71, 16, 12, 13]]
0
189
2
#include <stdio.h> #include <stdlib.h> #define nummax 100 #define arrmax 99 int top = 0, S[1000]; void push(int); int pop(); int main() { int i, num, x, y; char moji[nummax], a; while (scanf("%s", moji) != EOF) { if (moji[0] == '+') { x = pop(); y = pop(); push(x + y); } else if (moj...
#include <stdio.h> #include <stdlib.h> #define nummax 100 #define arrmax 99 int top = 0, S[1000]; void push(int); int pop(); int main() { int i, num, x, y; char moji[nummax], a; while (scanf("%s", moji) != EOF) { if (moji[0] == '+') { x = pop(); y = pop(); push(x + y); } else if (moj...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
0
233
4
#include <ctype.h> #include <stdio.h> #include <stdlib.h> #define MAX 110 void initialize(void); int isEmpty(void); int isFull(void); void push(int); int pop(void); int s[MAX]; int top; int main() { char c[100]; int a, b; while (scanf("%s", c) != EOF) { if (c[0] == '+' || c[0] == '*' || c[0] == '-') { ...
#include <ctype.h> #include <stdio.h> #include <stdlib.h> #define MAX 110 void initialize(void); int isEmpty(void); int isFull(void); void push(int); int pop(void); int s[MAX]; int top; int main() { char c[100]; int a, b; while (scanf("%s", c) != EOF) { if (c[0] == '+' || c[0] == '*' || c[0] == '-') { ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
0
328
4
#include <stdio.h> #include <stdlib.h> #include <string.h> int top, N[100]; void push(int x) { top++; N[top] = x; } int pop() { top--; return N[top + 1]; } int main() { char n[100]; int a, b, top = 0; while (scanf("%s", n) != EOF) { if (n[0] == '+') { a = pop(); b = pop(); push...
#include <stdio.h> #include <stdlib.h> #include <string.h> int top, N[1000]; void push(int x) { top++; N[top] = x; } int pop() { top--; return N[top + 1]; } int main() { char n[100]; int a, b, top = 0; while (scanf("%s", n) != EOF) { if (n[0] == '+') { a = pop(); b = pop(); pus...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
0
207
6
#include <stdio.h> #include <stdlib.h> #include <string.h> void pop(); void push(int); int top = 0; int stack[200]; int main() { int i = 0; char s[8]; while ((scanf("%s", s)) != EOF) { if (strcmp(s, "+") == 0) { stack[top - 1] = (stack[top]) + (stack[top - 1]); pop(); } else if (strcmp(s, "...
#include <stdio.h> #include <stdlib.h> #include <string.h> void pop(); void push(int); int top = 0; int stack[200]; int main() { int i = 0; char s[8]; while ((scanf("%s", s)) != EOF) { if (strcmp(s, "+") == 0) { stack[top - 1] = (stack[top]) + (stack[top - 1]); pop(); } else if (strcmp(s, "...
[["+", 12, 16, 31, 23, 0, 69, 71, 16, 17, 33], ["+", 12, 16, 31, 23, 0, 69, 71, 16, 12, 13], ["-", 12, 16, 12, 23, 0, 69, 71, 16, 17, 33], ["-", 12, 16, 12, 23, 0, 69, 71, 16, 12, 13]]
0
242
4