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
import time import copy def BubbleSort(A, N): flag = 1 while flag: flag = 0 for j in reversed(range(1, N)): if A[j]['value']<A[j-1]['value']: A[j], A[j-1] = A[j-1], A[j] flag = 1 return A def SelectionSort(A, N): for i in range(0, N): ...
import time import copy def BubbleSort(A, N): flag = 1 while flag: flag = 0 for j in reversed(range(1, N)): if A[j]['value']<A[j-1]['value']: A[j], A[j-1] = A[j-1], A[j] flag = 1 return A def SelectionSort(A, N): for i in range(0, N): ...
[["-", 0, 57, 15, 666, 0, 206, 206, 557, 0, 6], ["+", 0, 57, 15, 666, 0, 206, 206, 557, 0, 6]]
5
376
4
n = int(input()) a = list(map(str,input().split())) data1 = a[:] data2 = a[:] def bubble_sort(data): for i in range(len(data)): for j in range(len(data)-1,i,-1): if(data[j][1] < data[j-1][1]): data[j],data[j-1] = data[j-1],data[j] return(data) def selection_sort(data): for i in range(len(data)): minj ...
n = int(input()) a = list(map(str,input().split())) data1 = a[:] data2 = a[:] def bubble_sort(data): for i in range(len(data)): for j in range(len(data)-1,i,-1): if(data[j][1] < data[j-1][1]): data[j],data[j-1] = data[j-1],data[j] return(data) def selection_sort(data): for i in range(len(data)): minj ...
[["-", 0, 652, 3, 4, 0, 41, 0, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 41, 0, 557, 0, 6]]
5
240
2
n = eval(input()) b = input().split() s = list(b) for i in range(n): for j in range(n - 1, i, -1): if b[j][1] < b[j - 1][1]: b[j], b[j - 1] = b[j - 1], b[j] for i in range(n): mini = i for j in range(i, n): if s[j][1] < s[mini][1]: mini = j s[i], s[mini] = s[min...
n = eval(input()) b = input().split() s = list(b) for i in range(n): for j in range(n - 1, i, -1): if b[j][1] < b[j - 1][1]: b[j], b[j - 1] = b[j - 1], b[j] for i in range(n): mini = i for j in range(i, n): if s[j][1] < s[mini][1]: mini = j s[i], s[mini] = s[min...
[["-", 3, 4, 0, 23, 0, 41, 0, 557, 0, 6], ["+", 3, 4, 0, 23, 0, 41, 0, 557, 0, 6]]
5
196
2
def bubble(c): for i in range(len(c)): for j in range(len(c)-1,i,-1): if int(c[j][-1]) < int(c[j-1][-1]): c[j],c[j-1] = c[j-1],c[j] return c def selection(c): for i in range(len(c)): mini = i for j in range(i,len(c)): if int(c[j][-1])<int(c[mini][-1]): mini = j c[i],c[mini]=c[mini],c[i] return...
def bubble(c): for i in range(len(c)): for j in range(len(c)-1,i,-1): if int(c[j][-1]) < int(c[j-1][-1]): c[j],c[j-1] = c[j-1],c[j] return c def selection(c): for i in range(len(c)): mini = i for j in range(i,len(c)): if int(c[j][-1])<int(c[mini][-1]): mini = j c[i],c[mini]=c[mini],c[i] retur...
[["+", 0, 656, 0, 1, 0, 662, 12, 206, 0, 70], ["+", 0, 1, 0, 662, 12, 206, 206, 663, 0, 102], ["+", 0, 656, 0, 1, 0, 662, 12, 206, 0, 73]]
5
260
3
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_C # Stable Sort # Result: import sys ary_len = int(sys.stdin.readline()) ary_str = sys.stdin.readline().rstrip().split(' ') ary = [(int(s[1]), s) for s in ary_str] # a is an array of tupples whose format is like (4, 'C4'). def bubble_sort(a): a_le...
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_C # Stable Sort # Result: # Modifications # - modify inner loop start value of bubble_sort # This was the cause of the previous wrong answer. # - improve performance of is_stable function import sys ary_len = int(sys.stdin.readline()) ary_str = sys.s...
[["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
436
4
import collections Card = collections.namedtuple('Card', ['suit', 'value']) def bubble_sort(array): a = array[::] for i in range(len(a)): for j in reversed(range(i, len(a))): if a[j].value < a[j - 1].value: a[j], a[j - 1] = a[j - 1], a[j] return a def selection_sort(...
import collections Card = collections.namedtuple('Card', ['suit', 'value']) def bubble_sort(array): a = array[::] for i in range(len(a)): for j in reversed(range(i + 1, len(a))): if a[j].value < a[j - 1].value: a[j], a[j - 1] = a[j - 1], a[j] return a def selection_s...
[["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]]
5
330
2
N = int(input()) line = input() A = line.strip().split(" ") A2 = line.strip().split(" ") for i in range(0, N): min_j = i for j in range(i, N): if int(A2[j][1:]) < int(A2[min_j][1:]): min_j = j A2[i], A2[min_j] = A2[min_j], A2[i] bubble = " ".join(A2) flag = True while flag: flag = F...
N = int(input()) line = input() A = line.strip().split(" ") A2 = line.strip().split(" ") for i in range(0, N): min_j = i for j in range(i, N): if int(A2[j][1:]) < int(A2[min_j][1:]): min_j = j A2[i], A2[min_j] = A2[min_j], A2[i] select = " ".join(A2) flag = True while flag: flag = Fa...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22]]
5
241
4
n = int(input()) cards_b = input().split() cards_s = list(cards_b) # BubbleSort for i in range(n): for j in range(n - 1, i, -1): if int(cards_b[j][1]) < int(cards_b[j - 1][1]): cards_b[j], cards_b[j - 1] = cards_b[j - 1], cards_b[j] #SelectionSort for i in range(n): min_i = i for j in...
n = int(input()) cards_b = input().split() cards_s = list(cards_b) # BubbleSort for i in range(n): for j in range(n - 1, i, -1): if int(cards_b[j][1]) < int(cards_b[j - 1][1]): cards_b[j], cards_b[j - 1] = cards_b[j - 1], cards_b[j] #SelectionSort for i in range(n): min_i = i for j in...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
209
2
#!/usr/bin/env python3 # -*- coding: utf-8 -*- class Card(object): def __init__(self, card): self.card = card self.suit = card[0] self.value = int(card[1:]) def __str__(self): return str(self.card) def print_array(a): print(" ".join(map(str, a))) def bubblesort(cards,...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- class Card(object): def __init__(self, card): self.card = card self.suit = card[0] self.value = int(card[1:]) def __str__(self): return str(self.card) def print_array(a): print(" ".join(map(str, a))) def bubblesort(cards,...
[["+", 0, 1, 0, 662, 12, 206, 206, 663, 0, 102], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
332
4
# coding: utf-8 def bubble_sort(A, N): C = list(A) for i in range(N): for j in reversed(range(i, N)): if C[j][1] < C[j-1][1]: C[j], C[j-1] = C[j-1], C[j] return C def selection_sort(A, N): C = list(A) for i in range(N): minj = i for j in range(i,...
# coding: utf-8 def bubble_sort(A, N): C = list(A) for i in range(N): for j in reversed(range(i+1, N)): if C[j][1] < C[j-1][1]: C[j], C[j-1] = C[j-1], C[j] return C def selection_sort(A, N): C = list(A) for i in range(N): minj = i for j in range(...
[["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]]
5
353
2
def bubble_sort(a): n = len(a) for j in range(n): m = n-1-j # n-1 to 0 for i in range(m): if a[i][1] > a[i+1][1]: a[i],a[i+1] = a[i+1],a[i] return a def selection_sort(a): MAXINT = 10 n = len(a) for j in range(n): minv = MAXINT minp =...
def bubble_sort(a): n = len(a) for j in range(n): m = n-1-j # n-1 to 0 for i in range(m): if a[i][1] > a[i+1][1]: a[i],a[i+1] = a[i+1],a[i] return a def selection_sort(a): MAXINT = 10 n = len(a) for j in range(n): minv = MAXINT minp =...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
347
2
n, a = int(input()), input().split() ta = list((int(c[1]), i, c) for i, c in enumerate(a)) ca = sorted(ta) ba = ta[:] for i in range(n): for j in range(n - 1, i - 1, -1): if ba[j][0] < ba[j - 1][0]: ba[j], ba[j - 1] = ba[j - 1], ba[j] print(*[t[2] for t in ba]) print(('Not s' if ba != ca else ...
n, a = int(input()), input().split() ta = list((int(c[1]), i, c) for i, c in enumerate(a)) ca = sorted(ta) ba = ta[:] for i in range(n): for j in range(n - 1, i, -1): if ba[j][0] < ba[j - 1][0]: ba[j], ba[j - 1] = ba[j - 1], ba[j] print(*[t[2] for t in ba]) print(('Not s' if ba != ca else 'S')...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
263
2
class card: def __init__(self, types, value): self.types = types self.value = value def bubbleSort(A, N): for i in range(0, N): for j in range(N - 1, i - 1, -1): if A[j].value < A[j - 1].value: exchange(A, j - 1, j) printCards(A) print("Stable") def ...
class card: def __init__(self, types, value): self.types = types self.value = value def bubbleSort(A, N): for i in range(0, N): for j in range(N - 1, i, -1): if A[j].value < A[j - 1].value: exchange(A, j - 1, j) printCards(A) print("Stable") def sele...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
380
2
# -*- coding: utf-8 -*- N = int(input()) A = list(map(str, input().split())) B = A[:] for i in range(N): for j in range(N-1, i, -1): if int(A[j][1]) < int(A[j-1][1]): A[j], A[j-1] = A[j-1], A[j] bubble = " ".join(A) for i in range(N): minj = i for j in range(i, N): if int(B[j][1...
# -*- coding: utf-8 -*- N = int(input()) A = list(map(str, input().split())) B = A[:] for i in range(N): for j in range(N-1, i, -1): if int(A[j][1]) < int(A[j-1][1]): A[j], A[j-1] = A[j-1], A[j] bubble = " ".join(A) for i in range(N): minj = i for j in range(i, N): if int(B[j][1...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
222
2
def isStable(lis1, lis2): ret = True for i in range(len(lis1)-1): if lis1[i][1] == lis1[i+1][1]: ret = lis1[i+1] in lis2[(lis2.index(lis1[i])):] return ret N = int(input()) cards = input().split() B = list(cards) for i in range(N): for j in range(N-1, i, -1): if B[j][1] ...
def isStable(lis1, lis2): ret = True for i in range(len(lis1)-1): if lis1[i][1] == lis1[i+1][1]: ret = (lis1[i+1] in lis2[(lis2.index(lis1[i])+1):]) and ret return ret N = int(input()) cards = input().split() B = list(cards) for i in range(N): for j in range(N-1, i, -1): ...
[["+", 0, 1, 0, 662, 12, 679, 31, 23, 0, 24], ["+", 0, 206, 206, 663, 0, 23, 0, 657, 17, 72], ["+", 0, 206, 206, 663, 0, 23, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 679, 31, 23, 0, 25], ["+", 64, 196, 0, 1, 0, 662, 12, 679, 17, 355], ["+", 64, 196, 0, 1, 0, 662, 12, 679, 12, 22]]
5
283
6
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_C&lang=jp sample_input = list(range(3)) sample_input[0] = '''5 H4 C9 S4 D2 C3''' sample_input[1] = '''2 S1 H1''' sample_input[2] = '''5 H4 C9 S4 D2 C3''' give_sample_input = None if give_sample_input is not None: sample_input_list = sample_input[giv...
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_C&lang=jp sample_input = list(range(3)) sample_input[0] = '''5 H4 C9 S4 D2 C3''' sample_input[1] = '''2 S1 H1''' sample_input[2] = '''5 H4 C9 S4 D2 C3''' give_sample_input = None if give_sample_input is not None: sample_input_list = sample_input[giv...
[["+", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
565
6
import copy N = int(input()) bscs = [(int(c[-1]), c) for c in input().split(" ")] sscs = copy.copy(bscs) for i in range(N): j = N - 1 while j > i: if bscs[j][0] < bscs[j - 1][0]: tmp = bscs[j] bscs[j] = bscs[j - 1] bscs[j - 1] = tmp j -= 1 print(" ".join([c[1]...
import copy N = int(input()) bscs = [(int(c[-1]), c) for c in input().split(" ")] sscs = copy.copy(bscs) for i in range(N): j = N - 1 while j > i: if bscs[j][0] < bscs[j - 1][0]: tmp = bscs[j] bscs[j] = bscs[j - 1] bscs[j - 1] = tmp j -= 1 print(" ".join([c[1]...
[["-", 0, 652, 3, 4, 0, 41, 0, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 41, 0, 557, 0, 6]]
5
234
2
class card: def __init__(self,cv): c = cv[0:1] v = int(cv[1:2]) self.c = c self.v = v def self_str(self): q = str(str(self.c) + str(self.v)) return q n = int(input()) a = list(map(card, input().split())) b = a[:] c = a[:] for i in range(n): for j i...
class card: def __init__(self,cv): c = cv[0:1] v = int(cv[1:2]) self.c = c self.v = v def self_str(self): q = str(str(self.c) + str(self.v)) return q n = int(input()) a = list(map(card, input().split())) b = a[:] c = a[:] for i in range(n): for j i...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 612]]
5
486
2
#coding:UTF-8 def BS(N,A): for i in range(N): for j in reversed(range(i+1,N)): if int(A[j][1:])<int(A[j-1][1:]): swap=A[j] A[j]=A[j-1] A[j-1]=swap return A def SS(N,A): for i in range(N): minj=i for j in range(i,N): ...
#coding:UTF-8 def BS(N,A): for i in range(N): for j in reversed(range(i+1,N)): if int(A[j][1:])<int(A[j-1][1:]): swap=A[j] A[j]=A[j-1] A[j-1]=swap return A def SS(N,A): for i in range(N): minj=i for j in range(i,N): ...
[["-", 0, 14, 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, 21], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
351
6
def BubbleSort(a, n): for i in range(n): for j in range(n-1, i, -1): if int(a[j][1]) < int(a[j - 1][1]): a[j], a[j-1] = a[j-1], a[j] return a def SelectionSort(a, n): for i in range(n): mini = i for j in range(i, n): if int(a[j][1]) < int(a[m...
def BubbleSort(a, n): for i in range(n): for j in range(n-1, i, -1): if int(a[j][1]) < int(a[j - 1][1]): a[j], a[j-1] = a[j-1], a[j] return a def SelectionSort(a, n): for i in range(n): mini = i for j in range(i, n): if int(a[j][1]) < int(a[m...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
231
2
# -*- coding: utf-8 -*- def conv_input(arr): ret = [] for e in arr: ret.append((e[0], int(e[1]))) return ret def conv_output(conv_arr): ret = [] for e in conv_arr: ret.append(e[0] + str(e[1])) return ret def is_stable(arr1, arr2): ret = 'Stable' for a1, a2 in zip(ar...
# -*- coding: utf-8 -*- def conv_input(arr): ret = [] for e in arr: ret.append((e[0], int(e[1]))) return ret def conv_output(conv_arr): ret = [] for e in conv_arr: ret.append(e[0] + str(e[1])) return ret def is_stable(arr1, arr2): ret = 'Stable' for a1, a2 in zip(ar...
[["-", 8, 196, 0, 1, 0, 662, 12, 557, 0, 6], ["+", 8, 196, 0, 1, 0, 662, 12, 557, 0, 6]]
5
382
2
def selectionSort(a,b): for i in range(len(a)): mini = i for j in range(i,len(a)): if a[j] < a[mini]: mini = j if i != mini: ret = a[i] a[i] = a[mini] a[mini] = ret ret = b[i] b[i] =b[mini] b[...
def selectionSort(a,b): for i in range(len(a)): mini = i for j in range(i,len(a)): if a[j] < a[mini]: mini = j if i != mini: ret = a[i] a[i] = a[mini] a[mini] = ret ret = b[i] b[i] =b[mini] b[...
[["+", 0, 656, 0, 14, 8, 196, 0, 37, 0, 38], ["+", 0, 656, 0, 14, 8, 196, 0, 37, 0, 22]]
5
435
2
# coding: utf-8 # Here your code ! def BubbleSort(A, N): count = 0 flag = 1 while flag: flag = 0 for i in range(1, N): if int(A[N - i][1]) < int(A[N - i - 1][1]): A[N - i], A[N - i - 1] = A[N - i - 1], A[N - i] flag = 1 return A def Selectio...
# coding: utf-8 # Here your code ! def BubbleSort(A, N): count = 0 flag = 1 while flag: flag = 0 for i in range(1, N): if int(A[N - i][1]) < int(A[N - i - 1][1]): A[N - i], A[N - i - 1] = A[N - i - 1], A[N - i] flag = 1 return A def Selectio...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
272
2
N = eval(input()) A = list(map(str,input().split())) Ab = A[:] As = A[:] def BubbleSort(A,N): for i in range(N): flag = 0 for i in range(1,N): j = N - i if A[j][1] < A[j-1][1]: v = A[j] A[j] = A[j-1] A[j-1] = v ...
N = eval(input()) A = list(map(str,input().split())) Ab = A[:] As = A[:] def BubbleSort(A,N): for i in range(N): flag = 0 for i in range(1,N): j = N - i if A[j][1] < A[j-1][1]: v = A[j] A[j] = A[j-1] A[j-1] = v ...
[["-", 15, 679, 12, 666, 0, 206, 51, 206, 206, 612], ["+", 15, 679, 12, 666, 0, 206, 51, 206, 206, 22]]
5
397
2
N = int(input()) A1 = list(map(str,input().split())) A2 = A1[:] def bubbleSort(A, N): flag = 0 i = 0 while flag == 0: flag = 1 for j in range(N-1, i, -1): if A[j][1] < A[j-1][1]: A[j], A[j-1] = A[j-1], A[j] flag = 0 i += 1 return A def selectSort(A, N): for i in range(N): minj = i for j in r...
N = int(input()) A1 = list(map(str,input().split())) A2 = A1[:] def bubbleSort(A, N): flag = 0 i = 0 while flag == 0: flag = 1 for j in range(N-1, i, -1): if A[j][1] < A[j-1][1]: A[j], A[j-1] = A[j-1], A[j] flag = 0 i += 1 return A def selectSort(A, N): for i in range(N): minj = i for j in r...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
312
2
def bubble(A, N): flag = True while flag: flag = False for j in range(N-1, 0, -1): if int(A[j][-1]) < int(A[j-1][-1]): A[j], A[j-1] = A[j-1], A[j] flag = True return A def selection(A, N): for i in range(0, N): minj = i for j i...
def bubble(A, N): flag = True while flag: flag = False for j in range(N-1, 0, -1): if int(A[j][-1]) < int(A[j-1][-1]): A[j], A[j-1] = A[j-1], A[j] flag = True return A def selection(A, N): for i in range(0, N): minj = i for j i...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
253
2
def BubbleSort(N, C): C = [] + C for i in range(N): for j in range(N-1, i, -1): if C[j][1] < C[j-1][1]: C[j], C[j-1] = C[j-1], C[j] return C def SelectionSort(N, C): C = [] + C for i in range(N): minj = i for j in range(i, N): if C[mi...
def BubbleSort(N, C): C = [] + C for i in range(N): for j in range(N-1, i, -1): if C[j][1] < C[j-1][1]: C[j], C[j-1] = C[j-1], C[j] return C def SelectionSort(N, C): C = [] + C for i in range(N): minj = i for j in range(i, N): if C[mi...
[["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 25]]
5
287
2
N=int(input()) A=input().split() B=A[:] S=A[:] def BubbleSort(A, N): count = 0 flag = True while flag: flag = False for j in range(N-1, 0, -1): if A[j][1] < A[j-1][1]: A[j], A[j-1] = A[j-1], A[j] count += 1 flag = True ...
N=int(input()) A=input().split() B=A[:] S=A[:] def BubbleSort(A, N): count = 0 flag = True while flag: flag = False for j in range(N-1, 0, -1): if A[j][1] < A[j-1][1]: A[j], A[j-1] = A[j-1], A[j] count += 1 flag = True ...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
241
2
import copy N = int(input()) A = list(input().split()) def is_stable(sorted_list): for i in range(len(sorted_list)-1): if sorted_list[i][1] == sorted_list[i+1][1]: for j in range(len(A)): if A[j] == sorted_list[i]: smaller_idx = j if A[j] == ...
import copy N = int(input()) A = list(input().split()) def is_stable(sorted_list): for i in range(len(sorted_list)-1): if sorted_list[i][1] == sorted_list[i+1][1]: for j in range(len(A)): if A[j] == sorted_list[i]: smaller_idx = j if A[j] == ...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
370
2
n = int(input()) a = input().split() b = a[:] frag = 1 while frag: frag = 0 for i in range(n - 1): if a[i][1] > a[i + 1][1]: a[i], a[i + 1] = a[i + 1], a[i] frag = 1 print(*a) print("Stable") for i in range(n - 1): minj = i for j in range(i, n): if b[j][1] < b[minj][1]: minj = j b[i...
n = int(input()) a = input().split() b = a[:] frag = 1 while frag: frag = 0 for i in range(n - 1): if a[i][1] > a[i + 1][1]: a[i], a[i + 1] = a[i + 1], a[i] frag = 1 print(*a) print("Stable") for i in range(n - 1): minj = i for j in range(i, n): if b[j][1] < b[minj][1]: minj = j b[i...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
184
2
import copy n=int(input()) s=input().split(' ') s1=[] s2=[] s1=copy.deepcopy(s) s2=copy.deepcopy(s) def Bubble_Sort(n,s1): m=0 flag=1 while flag: flag=0 for i in range(1,n): j=n-i if int(s1[j][1])<int(s1[j-1][1]): a=s1[j] s1[j]=s1[j-1] s1[j-1]=a m+=1 flag=1 b=s1 return(b) def Selec...
import copy n=int(input()) s=input().split(' ') s1=[] s2=[] s1=copy.deepcopy(s) s2=copy.deepcopy(s) def Bubble_Sort(n,s1): m=0 flag=1 while flag: flag=0 for i in range(1,n): j=n-i if int(s1[j][1])<int(s1[j-1][1]): a=s1[j] s1[j]=s1[j-1] s1[j-1]=a m+=1 flag=1 b=s1 return(b) def Selec...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
301
2
n=int(input()) c=input().split();d=c[:] for i in range(n-1): for j in range(0,n-i-1): if c[j][1]>c[j+1][1]:c[j],c[j+1]=c[j+1],c[j] m=i for j in range(i,n): if d[m][1]>d[j][1]:m=j d[i],d[m]=d[m],d[i] print(*c);print("Stable") print(*d) print(['Not s','S'][b==s]+'table')
n=int(input()) c=input().split();d=c[:] for i in range(n-1): for j in range(0,n-i-1): if c[j][1]>c[j+1][1]:c[j],c[j+1]=c[j+1],c[j] m=i for j in range(i,n): if d[m][1]>d[j][1]:m=j d[i],d[m]=d[m],d[i] print(*c);print("Stable") print(*d) print(['Not s','S'][c==d]+'table')
[["-", 3, 4, 0, 657, 31, 206, 206, 666, 0, 22], ["+", 3, 4, 0, 657, 31, 206, 206, 666, 0, 22]]
5
180
14
count = int(input()); data = input().split(" "); def bubble_sort(data): # print(data); count = len(data); for i in range(count): for j in range(count - 1, i, -1): if data[j][1] < data[j - 1][1]: data[j], data[j - 1] = data[j - 1], data[j]; # print(data); def sel...
count = int(input()); data = input().split(" "); def bubble_sort(data): # print(data); count = len(data); for i in range(count): for j in range(count - 1, i, -1): if data[j][1] < data[j - 1][1]: data[j], data[j - 1] = data[j - 1], data[j]; # print(data); def sel...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
270
2
#!/usr/bin/python3 # -*- coding: utf-8 -*- import sys def bubble_sort(A): for i in range(len(A)): for x in range(len(A)-1, i, -1): if A[x][1] < A[x-1][1]: A[x], A[x-1] = A[x-1], A[x] def selection_sort(A): for i in range(len(A)): min_val = A[i][1] for x in ...
#!/usr/bin/python3 # -*- coding: utf-8 -*- import sys def bubble_sort(A): for i in range(len(A)): for x in range(len(A)-1, i, -1): if A[x][1] < A[x-1][1]: A[x], A[x-1] = A[x-1], A[x] def selection_sort(A): for i in range(len(A)): min_val = A[i][1] for x in ...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
316
2
def bubble_sort(c, n): x = c[:] for i in range(n): for k in range(n-1, i, -1): if x[k][1] < x[k-1][1]: x[k], x[k-1] = x[k-1], x[k] return x def selection_sort(c, n): x = c[:] for i in range(n): mink = i for k in range(i, n): if x[k][1]...
def bubble_sort(c, n): x = c[:] for i in range(n): for k in range(n-1, i, -1): if x[k][1] < x[k-1][1]: x[k], x[k-1] = x[k-1], x[k] return x def selection_sort(c, n): x = c[:] for i in range(n): mink = i for k in range(i, n): if x[k][1]...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
320
2
n = int(input()) l = [] for i in input().split(): t = [] for j in i: t += [j] l += [t] t = l[:] f = 0 for i in range(n): for j in range(n-1, 0, -1): if t[j][1] < t[j-1][1]: t[j], t[j-1] = t[j-1], t[j] elif t[j][1] == t[j-1][1]: f += 1 if l.index(t[j-1]) > l.index(t[j]) else 0 print(*["{0}{1...
n = int(input()) l = [] for i in input().split(): t = [] for j in i: t += [j] l += [t] t = l[:] f = 0 for i in range(n): for j in range(n-1, 0, -1): if t[j][1] < t[j-1][1]: t[j], t[j-1] = t[j-1], t[j] elif t[j][1] == t[j-1][1]: f += 1 if l.index(t[j-1]) > l.index(t[j]) else 0 print(*["{0}{1...
[["-", 0, 652, 3, 4, 0, 206, 206, 657, 31, 22], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 33], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612], ["+", 0, 666, 0, 652, 3, 4, 0, 206, 206, 22]]
5
355
4
n = int(input()) bLst = input().split() iLst = bLst for i in range(n): for j in range(n-1,i,-1): if bLst[j][1] < bLst[j-1][1]: bLst[j],bLst[j-1] = bLst[j-1],bLst[j] print(*bLst) print("Stable") for i in range(n): min = i for j in range(i,n): if iLst[j][1] < iLst[min][1]: ...
n = int(input()) *bLst, = input().split() iLst = bLst[:] for i in range(n): for j in range(n-1,i,-1): if bLst[j][1] < bLst[j-1][1]: bLst[j],bLst[j-1] = bLst[j-1],bLst[j] print(*bLst) print("Stable") for i in range(n): min = i for j in range(i,n): if iLst[j][1] < iLst[min][1]: ...
[["+", 0, 1, 0, 662, 31, 684, 0, 695, 0, 48], ["+", 0, 656, 0, 1, 0, 662, 31, 684, 0, 21], ["+", 0, 656, 0, 1, 0, 662, 12, 206, 0, 70], ["+", 0, 1, 0, 662, 12, 206, 206, 663, 0, 102], ["+", 0, 656, 0, 1, 0, 662, 12, 206, 0, 73], ["-", 36, 36, 0, 656, 0, 57, 64, 196, 0, 35]]
5
181
6
def bubble_sort(seq): for i in range(len(seq)): flag = 0 for j in range(len(seq)-1,i,-1): if seq[j-1][1] > seq[j][1]: seq[j-1],seq[j] = seq[j],seq[j-1] flag = 1 if flag == 0: break return seq def selection_sort(seq): for i in range(len(se...
def bubble_sort(seq): for i in range(len(seq)): flag = 0 for j in range(len(seq)-1,i,-1): if seq[j-1][1] > seq[j][1]: seq[j-1],seq[j] = seq[j],seq[j-1] flag = 1 if flag == 0: break return seq def selection_sort(seq): for i in range(len(se...
[["+", 0, 1, 0, 652, 3, 4, 0, 661, 0, 48]]
5
235
2
def selection_sort(A): steps = 0 N = len(A) for i in range(0, N): minj = i for j in range(i, N): if A[minj][0] > A[j][0]: minj = j if i != minj: steps += 1 A[minj], A[i] = A[i], A[minj] # [print(A[idx], end=' ') if idx != len(A) - ...
def selection_sort(A): steps = 0 N = len(A) for i in range(0, N): minj = i for j in range(i, N): if A[minj][0] > A[j][0]: minj = j if i != minj: steps += 1 A[minj], A[i] = A[i], A[minj] # [print(A[idx], end=' ') if idx != len(A) - ...
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
5
605
3
def bubbleSort(c): for i in range(0, len(c) - 1): for j in range(len(c)-1, i, -1): if c[j][1] < c[j-1][1]: c[j], c[j-1] = c[j-1], c[j] def selectionSort(c): for i in range(0, len(c)): minj = i for j in range(i, len(c)): if c[j][1] < c[minj][1]: ...
def bubbleSort(c): for i in range(0, len(c) - 1): for j in range(len(c)-1, i, -1): if c[j][1] < c[j-1][1]: c[j], c[j-1] = c[j-1], c[j] def selectionSort(c): for i in range(0, len(c)): minj = i for j in range(i, len(c)): if c[j][1] < c[minj][1]: ...
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79]]
5
268
2
def bubble_sort(n, key=0): c = 0 r = [x if isinstance(x, list) else [x] for x in n[:]] l = len(r) - 1 for i in range(0, l): for j in range(l, i, -1): if r[j][key] < r[j-1][key]: r[j], r[j-1] = r[j-1], r[j] c += 1 r = [x[0] if len(x) == 1 else x for...
def bubble_sort(n, key=0): c = 0 r = [x if isinstance(x, list) else [x] for x in n[:]] l = len(r) - 1 for i in range(0, l): for j in range(l, i, -1): if r[j][key] < r[j-1][key]: r[j], r[j-1] = r[j-1], r[j] c += 1 r = [x[0] if len(x) == 1 else x for...
[["-", 0, 652, 3, 4, 0, 41, 0, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 41, 0, 557, 0, 6]]
5
445
2
def BubbleSort(C, N): for i in range(N): for j in range(N-1, i, -1): if C[j][1] < C[j-1][1]: C[j], C[j-1] = C[j-1], C[j] return C def SelectionSort(C, N): for i in range(N): minj = i for j in range(i, N): if C[j][1] < C[minj][1]: ...
def BubbleSort(C, N): for i in range(N): for j in range(N-1, i, -1): if C[j][1] < C[j-1][1]: C[j], C[j-1] = C[j-1], C[j] return C def SelectionSort(C, N): for i in range(N): minj = i for j in range(i, N): if C[j][1] < C[minj][1]: ...
[["-", 0, 57, 64, 196, 0, 37, 0, 557, 0, 6], ["+", 0, 57, 64, 196, 0, 37, 0, 557, 0, 6], ["-", 0, 14, 8, 196, 0, 37, 0, 557, 0, 6], ["+", 0, 14, 8, 196, 0, 37, 0, 557, 0, 6]]
5
257
4
#coding:utf-8 from copy import deepcopy n = int(input()) A = list(input().split()) B = deepcopy(A) def BubbleSort(A,N): for i in range(N): for j in range(N-1,i,-1): if A[j][1] < A[j-1][1]: A[j], A[j-1] = A[j-1], A[j] def SelectionSort(A,N): for i in range(N): min...
#coding:utf-8 from copy import deepcopy n = int(input()) A = list(input().split()) B = deepcopy(A) def BubbleSort(A,N): for i in range(N): for j in range(N-1,i,-1): if A[j][1] < A[j-1][1]: A[j], A[j-1] = A[j-1], A[j] def SelectionSort(A,N): for i in range(N): min...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
249
2
def bubble_sort(a, n): for i in range(n): for j in range(n - 1, i, -1): if a[j]['value'] < a[j - 1]['value']: tmp = a[j] a[j] = a[j - 1] a[j - 1] = tmp def selection_sort(a, n): is_stable = True for i in range(n): minj = i ...
def bubble_sort(a, n): for i in range(n): for j in range(n - 1, i, -1): if a[j]['value'] < a[j - 1]['value']: tmp = a[j] a[j] = a[j - 1] a[j - 1] = tmp def selection_sort(a, n): is_stable = True for i in range(n): minj = i ...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
380
2
#!/usr/bin/env python #-*- coding: utf-8 -*- def selection_sort(l): N = len(l) for i in range(0, N): minj = i for j in range(i, N): if int(l[j][1]) < int(l[minj][1]): minj = j if i != minj: l[i], l[minj] = l[minj], l[i] def bubble_sort(l): ...
#!/usr/bin/env python #-*- coding: utf-8 -*- def selection_sort(l): N = len(l) for i in range(0, N): minj = i for j in range(i, N): if int(l[j][1]) < int(l[minj][1]): minj = j if i != minj: l[i], l[minj] = l[minj], l[i] def bubble_sort(l): ...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
255
2
def print_list(array): for i,e in enumerate(array): if i == N - 1: print(e) else: print(e, end=" ") def bubbleSort(): for i in range(N-1): for j in range(N-1, i, -1): if int(A[j][1:]) < int(A[j-1][1:]): w = A[j]; A[j] = A[j-1]; A[j-1] ...
def print_list(array): for i,e in enumerate(array): if i == N - 1: print(e) else: print(e, end=" ") def bubbleSort(): for i in range(N-1): for j in range(N-1, i, -1): if int(A[j][1:]) < int(A[j-1][1:]): w = A[j]; A[j] = A[j-1]; A[j-1] ...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
267
2
import sys class Card: def __init__(self, card): self.card = card self.mark = card[0] self.value = int(card[1]) def print_cards(arr_print, arr_compare): n = len(arr_print) same = True for i in range(n): if arr_compare != None and arr_print[i].card != arr_compare[i].card: same = False sys.stdout.write(st...
import sys class Card: def __init__(self, card): self.card = card self.symbol = card[0] self.value = int(card[1]) def print_cards(arr_print, arr_compare): n = len(arr_print) same = True for i in range(n): if arr_compare != None and arr_print[i].card != arr_compare[i].card: same = False sys.stdout.write(...
[["-", 8, 196, 0, 1, 0, 662, 31, 319, 319, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 319, 319, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 652, 3, 4, 0, 319, 0, 131], ["+", 0, 1, 0, 652, 3, 4, 0, 319, 319, 22]]
5
397
7
import copy N = int(input()) A = input().split() B = copy.copy(A) boo = 1 while boo: boo = 0 for i in range(N-1): if A[i][1] > A[i+1][1]: A[i], A[i+1] = A[i+1], A[i] boo = 1 print(*A) print("Stable") for i in range(N-1): mi = i for j in range(i,N): if B[i][1] > B[...
import copy N = int(input()) A = input().split() B = copy.copy(A) boo = 1 while boo: boo = 0 for i in range(N-1): if A[i][1] > A[i+1][1]: A[i], A[i+1] = A[i+1], A[i] boo = 1 print(*A) print("Stable") for i in range(N): mi = i for j in range(i,N): if B[mi][1] > B[j...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 57, 15, 666, 0, 206, 51, 206, 206, 22], ["+", 0, 57, 15, 666, 0, 206, 51, 206, 206, 22]]
5
193
4
def bubbleSort(cards, N): flag = True while flag: flag = False for j in range(N-1, 0, -1): if cards.numbers[j] < cards.numbers[j - 1]: cards.swap(j, j-1) flag = True return cards def selectionSort(cards,N): for i in range(N): minj = i ...
def bubbleSort(cards, N): flag = True while flag: flag = False for j in range(N-1, 0, -1): if cards.numbers[j] < cards.numbers[j - 1]: cards.swap(j, j-1) flag = True return cards def selectionSort(cards,N): for i in range(N): minj = i ...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
446
4
#include <stdio.h> #include <string.h> #define MAX 10000 typedef struct PP { char name[100000]; int time; } P; void initialize(); void enqueue(P); P dequeue(); int min(int, int); P Q[MAX]; int head, tail; int main() { int elaps = 0, c; int n, q, i; P u; initialize(); scanf("%d%d", &n, &q); for (i =...
#include <stdio.h> #include <string.h> #define MAX 100000 typedef struct PP { char name[1000]; int time; } P; void initialize(); void enqueue(P); P dequeue(); int min(int, int); P Q[MAX]; int head, tail; int main() { int elaps = 0, c; int n, q, i; P u; initialize(); scanf("%d%d", &n, &q); for (i = ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 39, 122, 8, 123, 0, 124, 49, 80, 81, 13], ["+", 39, 122, 8, 123, 0, 124, 49, 80, 81, 13]]
0
337
4
#include <stdio.h> #include <string.h> typedef struct proces { char name[10]; int t; int flag; } P; P S[100005]; int head, tail, n; void enqueue(P x) { S[tail] = x; tail = (tail + 1) % 100005; } P dequeue() { P x = S[head]; head = (head + 1) % 100005; return x; } int min(int x, int y) { if (x > y)...
#include <stdio.h> #include <string.h> typedef struct proces { char name[10]; int t; int flag; } P; P S[100005]; int head, tail, n; void enqueue(P x) { S[tail] = x; tail = (tail + 1) % 100005; } P dequeue() { P x = S[head]; head = (head + 1) % 100005; return x; } int min(int x, int y) { if (x > y)...
[["-", 0, 14, 8, 9, 0, 57, 64, 37, 0, 22], ["+", 0, 14, 8, 9, 0, 57, 64, 37, 0, 22], ["-", 8, 9, 0, 57, 75, 76, 0, 37, 0, 22], ["+", 8, 9, 0, 57, 75, 76, 0, 37, 0, 22]]
0
292
4
#include <stdio.h> #include <string.h> void enqueue(int, int); int dequeue(void); int Q[1001][2]; int firstQ, lastQ; char name[1001][11]; main() { int i, index; char inName[11]; int inTime; int elapsedTime = 0; int n, q; firstQ = 0; lastQ = 0; scanf("%d %d", &n, &q); for (index = 0; index < n;...
#include <stdio.h> #include <string.h> void enqueue(int, int); int dequeue(void); int Q[50000][2]; int firstQ, lastQ; char name[50000][11]; main() { int i, index; char inName[11]; int inTime; int elapsedTime = 0; int n, q; firstQ = 0; lastQ = 0; scanf("%d %d", &n, &q); for (index = 0; index < ...
[["-", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13]]
0
286
4
#include <stdio.h> #include <string.h> //構造体 typedef struct { char name[10]; int t; } Process; //プロトタイプ宣言 void enqueue(Process); Process dequeue(void); //グローバル変数 Process Q[1000]; int n, q; int ttime; int i, j; int main(void) { int count = 0; Process stack[1000]; scanf("%d %d", &n, &q); //スケジュールの入力 ...
#include <stdio.h> #include <string.h> //構造体 typedef struct { char name[10]; int t; } Process; //プロトタイプ宣言 void enqueue(Process); Process dequeue(void); //グローバル変数 Process Q[100000]; int n, q; int ttime; int i, j; int main(void) { int count = 0; Process stack[1000]; scanf("%d %d", &n, &q); //スケジュールの入力 ...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
0
318
2
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; int head = 0, tail = 0, n; void enqueue(P x) { Q[tail] = x; if (tail + 1 == LEN) { tail = 0; } else { tail = tail + 1; } } P dequeue() { P x = Q[head]; if (head + 1 == LEN)...
#include <stdio.h> #include <string.h> #define LEN 100001 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; int head = 0, tail = 0, n; void enqueue(P x) { Q[tail] = x; if (tail + 1 == LEN) { tail = 0; } else { tail = tail + 1; } } P dequeue() { P x = Q[head]; if (head + 1 == LEN)...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]]
0
262
8
public class Main { static int head, tail; public void run(java.io.InputStream in, java.io.PrintStream out) { java.util.Scanner sc = new java.util.Scanner(in); /*answer*/ int n, q; String[] name; int[] time; int i, t, a; String s; n = sc.nextInt(); q = sc.nextInt(); name = n...
public class Main { static int head, tail; public void run(java.io.InputStream in, java.io.PrintStream out) { java.util.Scanner sc = new java.util.Scanner(in); /*answer*/ int n, q; String[] name; int[] time; int i, t, a; String s; n = sc.nextInt(); q = sc.nextInt(); name = n...
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 499], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22]]
3
445
6
import java.io.*; import java.util.*; import java.util.Arrays; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] fst = (br.readLine()).split(" "); int n = Integer.parseInt(fst[0]); int quan = Int...
import java.io.*; import java.util.*; import java.util.Arrays; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] fst = (br.readLine()).split(" "); int n = Integer.parseInt(fst[0]); int quan = Int...
[["-", 8, 196, 0, 52, 15, 15, 0, 16, 12, 499], ["+", 8, 196, 0, 52, 15, 15, 0, 16, 12, 499]]
3
292
2
import java.util.ArrayDeque; import java.util.Deque; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int q = sc.nextInt(); Deque<String> nameQueue = new ArrayDeque<S...
import java.util.ArrayDeque; import java.util.Deque; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int q = sc.nextInt(); Deque<String> nameQueue = new ArrayDeque<S...
[["-", 0, 57, 15, 15, 0, 16, 31, 16, 12, 499], ["+", 0, 57, 15, 15, 0, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 492, 3, 4, 0, 16, 12, 499], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 12, 22], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 12, 499], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 22]]
3
252
6
import java.util.Scanner; public class Main { public Main() {} private Scanner sc; public static void main(String[] args) { new Main().solve(); } private void solve() { sc = new Scanner(System.in); int n = sc.nextInt(); int q = sc.nextInt(); MyQueue queue = new MyQueue(); for (int i = 0...
import java.util.Scanner; public class Main { public Main() {} private Scanner sc; public static void main(String[] args) { new Main().solve(); } private void solve() { sc = new Scanner(System.in); int n = sc.nextInt(); int q = sc.nextInt(); MyQueue queue = new MyQueue(); for (int i = 0...
[["-", 0, 1, 0, 11, 12, 227, 497, 505, 0, 499], ["+", 0, 1, 0, 11, 12, 227, 497, 505, 0, 499]]
3
339
2
import java.io.File; import java.io.FileNotFoundException; import java.lang.management.ManagementFactory; import java.lang.management.ThreadMXBean; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.PriorityQueue; import java.util.Scanner; pub...
import java.io.File; import java.io.FileNotFoundException; import java.lang.management.ManagementFactory; import java.lang.management.ThreadMXBean; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.PriorityQueue; import java.util.Scanner; pub...
[["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
3
408
2
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int count = sc.nextInt(); int q = sc.nextInt(); int totalTime = 0; String[] queue = new String[1000]; int[] restTime = new int[1000]; for (int i...
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int count = sc.nextInt(); int q = sc.nextInt(); int totalTime = 0; String[] queue = new String[200000]; int[] restTime = new int[200000]; for (i...
[["-", 0, 503, 49, 200, 51, 227, 497, 505, 0, 499], ["+", 0, 503, 49, 200, 51, 227, 497, 505, 0, 499]]
3
222
4
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.Queue; public class Main { public static final int BIG_NUM = 2000000000; public static final int MOD = 1000000007; public static void main(String[] args) { BufferedRea...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.Queue; public class Main { public static final int BIG_NUM = 2000000000; public static final int MOD = 1000000007; public static void main(String[] args) { BufferedRea...
[["-", 0, 246, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 0, 246, 8, 196, 0, 1, 0, 492, 141, 22], ["-", 0, 1, 0, 492, 3, 4, 0, 5, 0, 62], ["-", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491], ["-", 8, 196, 0, 1, 0, 492, 3, 4, 0, 21], ["-", 0, 1, 0, 492, 3, 4, 0, 492, 500, 22], ["+", 0, 1, 0, 492, 3, 4, 0, 492, 500, 22]]
3
451
8
import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); LinkedList<Process> processQueue = new LinkedList<Process>(); int n = sc.nextInt(); int quantum = sc.nextInt(); for (int i = 0; i < n; i++) {...
import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); LinkedList<Process> processQueue = new LinkedList<Process>(); int n = sc.nextInt(); int quantum = sc.nextInt(); for (int i = 0; i < n; i++) {...
[["-", 75, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 17, 33]]
3
312
2
#include <stdio.h> #define LEN 100005 /* プロセスを表す構造体 */ /* struct pp は長い!簡単にPと書きたい。 typedef で名前を付けなおす */ typedef struct pp { char name[100]; int t; } P; P Q[LEN]; int head, tail, n; void enqueue(P x) { Q[tail] = x; tail = (tail + 1) % LEN; } P dequeue(void) { /* headをxに取り出す */ P x = Q[head]; head = (he...
#include <stdio.h> #define LEN 100005 typedef struct pp { char name[100]; int t; } P; P Q[LEN]; int head, tail, n; void enqueue(P x) { Q[tail] = x; tail = (tail + 1) % LEN; } P dequeue(void) { P x = Q[head]; head = (head + 1) % LEN; return x; } int min(int a, int b) { return a < b ? a : b; } int ma...
[["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67]]
0
273
5
#include <stdio.h> #define len 100005 int head, tail; typedef struct { int time; char name[100]; } P; P Q[len]; int head, tail; void enquece(P x) { Q[tail] = x; tail = (tail + 1) % len; } P dequece() { P x = Q[head]; head = (head + 1) % len; return x; } int min(int a, int b) { return a < b ? a : b; } ...
#include <stdio.h> #define len 100005 int head, tail; typedef struct { int time; char name[100]; } P; P Q[len]; int head, tail; void enquece(P x) { Q[tail] = x; tail = (tail + 1) % len; } P dequece() { P x = Q[head]; head = (head + 1) % len; return x; } int min(int a, int b) { return a < b ? a : b; } ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
0
272
2
#include <stdio.h> #include <string.h> #define LEN 100005 // プロセスを表す構造体 typedef struct pp { char name[100]; int t; } P; // Pと同じ構造で長さがLENの構造体Qを作る P Q[LEN]; int head, tail, n; // 引数がPとxであり,xをQの末尾につけ,末尾を指すインデックスの数字を一つ増やし,あまりを取る void enqueue(P x) { Q[tail] = x; tail = (tail + 1) % LEN; } // Pの構造体でxを参照し,Qの先頭をPの...
#include <stdio.h> #include <string.h> #define LEN 100005 // プロセスを表す構造体 typedef struct pp { char name[100]; int t; } P; // Pと同じ構造で長さがLENの構造体Qを作る P Q[LEN]; int head, tail, n; // 引数がPとxであり,xをQの末尾につけ,末尾を指すインデックスの数字を一つ増やし,あまりを取る void enqueue(P x) { Q[tail] = x; tail = (tail + 1) % LEN; } // Pの構造体でxを参照し,Qの先頭をPのx...
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
0
276
2
#include <stdio.h> #include <string.h> #define LEN 100005 //プロセスを表わす構造体 typedef struct pp { char name[100]; int t; } P; P Q[LEN]; //ポインタ型 int head, tail, n; void enqueue(P x) { Q[tail] = x; tail = (tail + 1) % LEN; } P dequeue() { P x = Q[head]; head = (head + 1) % LEN; return x; } int min(int a, int...
#include <stdio.h> #include <string.h> #define LEN 100005 //プロセスを表わす構造体 typedef struct pp { char name[100]; int t; } P; P Q[LEN]; //ポインタ型 int head, tail, n; void enqueue(P x) { Q[tail] = x; tail = (tail + 1) % LEN; } P dequeue() { P x = Q[head]; head = (head + 1) % LEN; return x; } int min(int a, int...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
266
1
#include <stdio.h> #define MAX 100000 typedef struct { char name[10]; int time; } Queue; void initialize(void); void enqueue(Queue); Queue dequeue(void); int isEmpty(void); int isFull(void); Queue queue[MAX]; int head; int tail; main() { int n, q, i, sum; Queue box; sum = 0; scanf("%d%d", &n, &q); ...
#include <stdio.h> #define MAX 100000 typedef struct { char name[10]; int time; } Queue; void initialize(void); void enqueue(Queue); Queue dequeue(void); int isEmpty(void); int isFull(void); Queue queue[MAX]; int head; int tail; main() { int n, q, i, sum; Queue box; sum = 0; scanf("%d%d", &n, &q); ...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47]]
0
362
2
#include <stdio.h> #include <string.h> #define N 100000 typedef struct { int time; char name[10]; } data; int head, tail, x; int enqueue(data); data dequeue(void); int mix(int, int); data Q[N]; main() { int i, j, c = 0, e; data b; scanf("%d%d", &x, &e); for (i = 0; i < x; i++) { scanf("%s%d", Q[i].n...
#include <stdio.h> #include <string.h> #define N 100000 typedef struct { int time; char name[10]; } data; int head, tail, x; void enqueue(data); data dequeue(void); int mix(int, int); data Q[N]; main() { int i, j, c = 0, e; data b; scanf("%d%d", &x, &e); for (i = 1; i <= x; i++) { scanf("%s%d", Q[i]...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["-", 0, 30, 0, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 30, 0, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 30, 0, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 30, 0, 9, 0, 7, 15, 16, 17, 19], ["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36...
0
277
10
#include <stdio.h> typedef struct { char c[20]; int d; } X; int main() { int a, b, i, e = 0; scanf("%d %d", &a, &b); X x[1000000]; for (i = 0; i < a; i++) { scanf("%s %d", x[i].c, &x[i].d); } for (i = 0; i < a; i++) { x[i].d -= b; if (x[i].d <= 0) { e += x[i].d + b; printf("%s %d...
#include <stdio.h> typedef struct { char c[20]; int d; } X; int main() { int a, b, i, e = 0; scanf("%d %d", &a, &b); X x[200000]; for (i = 0; i < a; i++) { scanf("%s %d", x[i].c, &x[i].d); } for (i = 0; i < a; i++) { x[i].d -= b; if (x[i].d <= 0) { e += x[i].d + b; printf("%s %d\...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
178
2
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct P { char name[100]; int time; } P; int tail, head, n; P Q[LEN]; void enqueue(P x) { Q[tail] = x; tail = (tail + 1) % LEN; } P dequeue() { P x = Q[head]; head = (head + 1) % LEN; return x; } int min(int a, int b) { return a < b ...
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct P { char name[100]; int time; } P; int tail, head, n; P Q[LEN]; void enqueue(P x) { Q[tail] = x; tail = (tail + 1) % LEN; } P dequeue() { P x = Q[head]; head = (head + 1) % LEN; return x; } int min(int a, int b) { return a < b ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35]]
0
262
4
#include <stdio.h> #include <string.h> #define QUEUE_MAX 100005 #define NAME_MAX 100 #define HEAD_INIT 1 #define PROCESS_END 0 #define TAIL_END 1 #define VER_INIT 0 #define LOOP_INIT 0 #define EXIT_SUCCESS 0 #define NEXT_ITEM(x) ((x) + 1) typedef struct { unsigned char aubG_Dp_name[NAME_MAX]; signed long slG_Drem...
#include <stdio.h> #include <string.h> #define QUEUE_MAX 100005 #define NAME_MAX 100 #define HEAD_INIT 1 #define PROCESS_END 0 #define TAIL_END 1 #define VER_INIT 0 #define LOOP_INIT 1 #define EXIT_SUCCESS 0 #define NEXT_ITEM(x) ((x) + 1) typedef struct { unsigned char aubG_Dp_name[NAME_MAX]; signed long slG_Drem...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
0
331
4
#include <stdio.h> #include <string.h> #define MAX 100005 typedef struct PP { int t; char name[100]; } P; P Q[MAX]; int head, tail, n; void enqueue(P u) { Q[tail] = u; tail = (tail + 1) % MAX; } P dequeue() { P x = Q[head]; head = (head + 1) % MAX; return x; } int min(int a, int b) { return a < b ? a...
#include <stdio.h> #include <string.h> #define MAX 100005 typedef struct PP { int t; char name[100]; } P; P Q[MAX]; int head, tail, n; void enqueue(P u) { Q[tail] = u; tail = (tail + 1) % MAX; } P dequeue() { P x = Q[head]; head = (head + 1) % MAX; return x; } int min(int a, int b) { return a < b ? a...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
256
1
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; P Q2[LEN + 1]; int head = 0, tail = 0, n; void enqueue(P x) { Q[tail] = x; if ((tail + 1) == LEN) tail = 0; else tail++; } P dequeue() { P x; x = Q[head]; if ((head + 1) =...
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; P Q2[LEN + 1]; int head = 0, tail = 0, n; void enqueue(P x) { Q[tail] = x; if ((tail + 1) == LEN) tail = 0; else tail++; } P dequeue() { P x; x = Q[head]; if ((head + 1) =...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]]
0
293
2
#include <stdio.h> #include <string.h> #define N 100000 #define L 10 typedef struct qe { char name[L]; int tim; } Q; Q Qlem[N]; int head, tail, n; void enqueue(Q); Q dequeue(void); int min(int, int); int main() { int elaps = 0, cha, i, q; Q user; scanf("%d %d", &n, &q); for (i = 0; i < n; i++) { sca...
#include <stdio.h> #include <string.h> #define N 100000 #define L 100 typedef struct qe { char name[L]; int tim; } Q; Q Qlem[N]; int head, tail, n; void enqueue(Q); Q dequeue(void); int min(int, int); int main() { int elaps = 0, cha, i, q; Q user; scanf("%d %d", &n, &q); for (i = 1; i <= n; i++) { s...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
0
286
6
#include <stdio.h> #include <string.h> #define LEN 100005 #define MAX 100005 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; int head, tail, n; void enqueue(P x) { Q[tail] = x; if (tail + 1 == MAX) tail = 0; else tail++; } P dequeue(void) { P x; x = Q[head]; if (head + 1 == MAX...
#include <stdio.h> #include <string.h> #define LEN 100005 #define MAX 100005 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; int head, tail, n; void enqueue(P x) { Q[tail] = x; if (tail + 1 == MAX) tail = 0; else tail++; } P dequeue(void) { P x; x = Q[head]; if (head + 1 == MAX...
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
0
268
4
#include <stdio.h> #include <string.h> #define MAX 1000 typedef struct { int time; char name[10]; } queue; queue Q[MAX]; int head, tail; void enqueue(queue); queue dequeue(void); int main() { int i, n, Time, sum; queue q; scanf("%d %d", &n, &Time); for (i = 0; i < n; i++) { scanf("%s", Q[i].name);...
#include <stdio.h> #include <string.h> #define MAX 1000000 typedef struct { int time; char name[10]; } queue; queue Q[MAX]; int head, tail; void enqueue(queue); queue dequeue(void); int main() { int i, n, Time, sum; queue q; scanf("%d %d", &n, &Time); for (i = 0; i < n; i++) { scanf("%s", Q[i].nam...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
0
237
2
#include <stdio.h> #include <stdlib.h> #define MAX 100005 typedef struct { char name[100]; int time; } Process; int isempty(void); int isfull(void); void enqueue(Process); Process dequeue(void); Process List[MAX + 1]; int head, tail, n; int main() { int sum = 0, c; int i, q; Process box; scanf("%d %d",...
#include <stdio.h> #include <stdlib.h> #define MAX 100005 typedef struct { char name[100]; int time; } Process; int isempty(void); int isfull(void); void enqueue(Process); Process dequeue(void); Process List[MAX + 1]; int head, tail, n; int main() { int sum = 0, c; int i, q; Process box; scanf("%d %d",...
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
0
361
4
#include <stdio.h> #include <string.h> #define LEN 100005 #define MAX 100005 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; int head, tail, n; void enqueue(P x) { Q[tail] = x; if (tail + 1 == MAX) tail = 0; else tail++; } P dequeue(void) { P x; x = Q[head]; if (head + 1 == MAX...
#include <stdio.h> #include <string.h> #define LEN 100005 #define MAX 100005 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; int head, tail, n; void enqueue(P x) { Q[tail] = x; if (tail + 1 == MAX) tail = 0; else tail++; } P dequeue(void) { P x; x = Q[head]; if (head + 1 == MAX...
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1,...
0
278
8
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct pp { char name[100]; int t; } P; void initialize(void); int isEmpty(void); int isFull(void); void enqueue(P); P dequeue(void); P Q[LEN + 1]; int head, tail, n; void initialize() { head = tail = 0; } int isEmpty() { return head == tail; } ...
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct pp { char name[100]; int t; } P; void initialize(void); int isEmpty(void); int isFull(void); void enqueue(P); P dequeue(void); P Q[LEN + 1]; int head, tail, n; void initialize() { head = tail = 0; } int isEmpty() { return head == tail; } ...
[["-", 8, 9, 0, 52, 15, 23, 0, 16, 17, 98], ["-", 0, 52, 15, 23, 0, 16, 12, 16, 31, 22], ["-", 0, 52, 15, 23, 0, 16, 12, 16, 17, 18], ["-", 0, 52, 15, 23, 0, 16, 12, 16, 12, 13]]
0
366
4
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; int head = 0, tail = 0, n; void enqueue(P); P dequeue(void); int main() { int elaps = 0, c = 0; int i, q; P u; scanf("%d%d", &n, &q); for (i = 1; i <= n; i++) { scanf("%s", Q[i]...
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; int head = 0, tail = 0, n; void enqueue(P); P dequeue(void); int main() { int elaps = 0, c = 0; int i, q; P u; scanf("%d%d", &n, &q); for (i = 1; i <= n; i++) { scanf("%s", Q[i]...
[["-", 8, 9, 0, 52, 15, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 52, 15, 23, 0, 16, 12, 22]]
0
329
2
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct pp { char name[100]; int t; } P; void enqueue(P); P dequeue(); P Q[LEN + 1]; int head, tail, n; int main() { int elaps = 0, c = 0; int i = 0, q; P u; scanf("%d %d", &n, &q); for (i = 1; i <= n; i++) { scanf("%s", Q[i].name)...
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct pp { char name[100]; int t; } P; void enqueue(P); P dequeue(); P Q[LEN + 1]; int head, tail, n; int main() { int elaps = 0, c = 0; int i = 0, q; P u; scanf("%d %d", &n, &q); for (i = 1; i <= n; i++) { scanf("%s", Q[i].name)...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]]
0
272
6
#include <stdio.h> #include <string.h> #define N 1000 /* Q's length */ /* P's member */ typedef struct { char name[100]; int t; } P; P Q[N]; /* make Q */ int head, tail, n; void enqueue(P x) { Q[tail] = x; tail++; } P dequeue() { P x = Q[head]; head++; return x; } /* small number return */ int mini(i...
#include <stdio.h> #include <string.h> #define N 1000000 /* Q's length */ /* P's member */ typedef struct { char name[100]; int t; } P; P Q[N]; /* make Q */ int head, tail, n; void enqueue(P x) { Q[tail] = x; tail++; } P dequeue() { P x = Q[head]; head++; return x; } /* small number return */ int min...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
0
249
2
#include <stdio.h> #include <string.h> #define LEN 100000 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; int head = 1, tail = 1, n; void enqueue(P x) { Q[tail] = x; if (tail + 1 == LEN) { tail = 0; } else { tail++; } } P dequeue() { P a; a = Q[head]; if (head + 1 == LEN) { ...
#include <stdio.h> #include <string.h> #define LEN 1000000 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; int head = 1, tail = 1, n; void enqueue(P x) { Q[tail] = x; if (tail + 1 == LEN) { tail = 0; } else { tail++; } } P dequeue() { P a; a = Q[head]; if (head + 1 == LEN) {...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47]]
0
302
4
#include <stdio.h> #include <string.h> #define LEN 1000 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; int head, tail, n; void enqueue(P); P dequeue(); int main() { int elaps = 0, c = 0; int i, q; P u; scanf("%d %d", &n, &q); for (i = 1; i <= n; i++) { scanf("%s", Q[i].name); s...
#include <stdio.h> #include <string.h> #define LEN 1000005 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; int head, tail, n; void enqueue(P); P dequeue(); int main() { int elaps = 0, c = 0; int i, q; P u; scanf("%d %d", &n, &q); for (i = 1; i <= n; i++) { scanf("%s", Q[i].name); ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
0
256
2
#include <stdio.h> #include <string.h> #define LEN 100000 typedef struct proc { char name[100]; int t; } process; int n; int head = 0, tail = 1; process queue[LEN + 1]; void enqueue(process x) { queue[tail] = x; if (tail + 1 == LEN) tail = 0; else tail++; } void dequeue() { if (head + 1 == LEN) ...
#include <stdio.h> #include <string.h> #define LEN 100000 typedef struct proc { char name[100]; int t; } process; int n; int head = 0, tail = 0; process queue[LEN + 1]; void enqueue(process x) { queue[tail] = x; if (tail + 1 == LEN) tail = 0; else tail++; } void dequeue() { if (head + 1 == LEN) ...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
0
255
2
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct pp { char name[100]; int t; } P; int initialize(); int isEmpty(); int isFull(); void enqueue(P); P dequeue(); P Q[LEN + 1]; int head, tail, n; int main() { int elaps = 0; int i, q; P u; scanf("%d %d", &n, &q); for (i = 1; i <= ...
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct pp { char name[100]; int t; } P; int initialize(); int isEmpty(); int isFull(); void enqueue(P); P dequeue(); P Q[LEN + 1]; int head, tail, n; int main() { int elaps = 0; int i, q; P u; scanf("%d %d", &n, &q); for (i = 1; i <= ...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47]]
0
374
2
#include <stdio.h> #include <string.h> #define N 1000000 int main() { int i, j, n, q, a = 0, time[N], count = 0; char name[N][10]; while (1) { scanf("%d %d", &n, &q); if (1 <= n && n <= N) break; } for (i = 0; i < n; i++) { if (scanf("%s %d", name[i], &time[i]) != 2) break; } ...
#include <stdio.h> #include <string.h> #define N 200000 int main() { int i, j, n, q, a = 0, time[N], count = 0; char name[N][10]; while (1) { scanf("%d %d", &n, &q); if (1 <= n && n <= N) break; } for (i = 0; i < n; i++) { if (scanf("%s %d", name[i], &time[i]) != 2) break; } ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
0
213
2
/* Elementary data structures - Queue */ #include <stdio.h> #define N 200000 typedef struct { int time; char name[20]; } node; node queue[N]; int start = 0; int end = 0; void enqueue(node x) { queue[end++] = x; if (end == N) end = 0; } node dequeue() { int tmp = start++; if (start == N) start =...
/* Elementary data structures - Queue */ #include <stdio.h> #define N 200000 typedef struct { int time; char name[20]; } node; node queue[N]; int start = 0; int end = 0; void enqueue(node x) { queue[end++] = x; if (end == N) end = 0; } node dequeue() { int tmp = start++; if (start == N) start =...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]]
0
253
4
#include <stdio.h> int index[1000000]; int head, tail; int sum; typedef struct { char name[10]; int t; } data; data d[100000]; void put(int n) { index[tail++] = n; } int get() { return index[head++]; } void process(int q) { int x; while (tail != head) { x = get(); if (d[x].t > q) { d[x].t = d...
#include <stdio.h> int index[1000000]; int head, tail; int sum; typedef struct { char name[10]; int t; } data; data d[100000]; void put(int n) { index[tail++] = n; } int get() { return index[head++]; } void process(int q) { int x; while (tail != head) { x = get(); if (d[x].t > q) { d[x].t = d...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]]
0
248
2
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct { char name[100]; int t; } Process; Process Q[LEN]; int head, tail, n; void enqueue(Process x) { Q[tail] = x; tail = (tail + 1) % LEN; } Process dequeue() { Process x = Q[head]; head = (head + 1) % LEN; return x; } int min(int a...
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct { char name[100]; int t; } Process; Process Q[LEN]; int head, tail, n; void enqueue(Process x) { Q[tail] = x; tail = (tail + 1) % LEN; } Process dequeue() { Process x = Q[head]; head = (head + 1) % LEN; return x; } int min(int a...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
263
1
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 10 typedef struct __queue_ { char name[MAX]; int time; struct __queue_ *next; } __queue_t; int main() { __queue_t *head = malloc(sizeof(__queue_t)); __queue_t *tail = head; tail->next = NULL; int n, q, now = 0; scanf("%d %d", &n, ...
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 10 typedef struct __queue_ { char name[MAX]; int time; struct __queue_ *next; } __queue_t; int main() { __queue_t *head = malloc(sizeof(__queue_t)); __queue_t *tail = head; tail->next = NULL; int n, q, now = 0; scanf("%d %d", &n, ...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 19]]
0
247
2
#include <stdio.h> #define LEN 100005 typedef struct pp { char name[11]; int t; } P; int head, tail, n; P Q[LEN]; int min(int a, int b); P dequeue(void); void enqueue(P x); int main(void) { int elaps = 0, c; int i, q; P u; scanf("%d %d", &n, &q); for (i = 1; i <= n; i++) { scanf("%s %d", Q[i].name, &Q...
#include <stdio.h> #define LEN 100005 typedef struct pp { char name[11]; int t; } P; int head, tail, n; P Q[LEN]; int min(int a, int b); P dequeue(void); void enqueue(P x); int main(void) { int elaps = 0, c; int i, q; P u; scanf("%d %d", &n, &q); for (i = 1; i <= n; i++) { scanf("%s %d", Q[i].name, &Q...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
279
1
#include <stdio.h> #include <stdlib.h> typedef struct { char name[10]; int time; } process; int main() { int head = 0, end, ead, count = 0, n, q; process *p; int i; scanf("%d%d", &n, &q); end = n; p = (process *)malloc(sizeof(int) * (n + 1)); for (i = 0; i < n; i++) { scanf("%s", p[i].name); ...
#include <stdio.h> #include <stdlib.h> typedef struct { char name[10]; int time; } process; int main() { int head = 0, end, ead, count = 0, n, q; process *p; int i; scanf("%d%d", &n, &q); end = n; p = (process *)malloc(sizeof(process) * (n + 1)); for (i = 0; i < n; i++) { scanf("%s", p[i].name);...
[["-", 3, 4, 0, 16, 31, 105, 39, 77, 39, 40], ["+", 3, 4, 0, 16, 31, 105, 51, 23, 0, 22]]
0
275
2
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; int head, tail, n; void enqueue(P x) { Q[tail] = x; if (tail == LEN) tail = 0; else tail++; } P dequeue() { P x = Q[head]; if (head == LEN) head = 0; else head++; ...
#include <stdio.h> #include <string.h> #define LEN 100005 typedef struct pp { char name[100]; int t; } P; P Q[LEN + 1]; int head, tail, n; void enqueue(P x) { Q[tail] = x; if (tail == LEN) tail = 0; else tail++; } P dequeue() { P x = Q[head]; if (head == LEN) head = 0; else head++; ...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
0
241
4
#include <inttypes.h> #include <stdint.h> #include <stdio.h> #define PROCESS_MAX 100001 typedef struct { char name[11]; uint_fast32_t time; } s_process; int main(void) { uint_fast32_t n, q, head = 0, tail = 0, process_time = 0; s_process process[PROCESS_MAX]; scanf("%" SCNu32 " %" SCNu32, &n, &q); for (u...
#include <inttypes.h> #include <stdint.h> #include <stdio.h> #define PROCESS_MAX 100001 typedef struct { char name[11]; uint_fast32_t time; } s_process; int main(void) { uint_fast32_t n, q, head = 0, tail = 0, process_time = 0; s_process process[PROCESS_MAX]; scanf("%" SCNu32 " %" SCNu32, &n, &q); for (u...
[["-", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22]]
0
224
2
#include <stdio.h> #include <stdlib.h> typedef struct { char name[11]; int time; } process; typedef struct node { process data; struct node *next; struct node *prev; } queue; queue *head = NULL; queue *last = NULL; void Push_back(process); process Pop_front(void); main() { int n, q, count = 0; process pro...
#include <stdio.h> #include <stdlib.h> typedef struct { char name[11]; int time; } process; typedef struct node { process data; struct node *next; struct node *prev; } queue; queue *head = NULL; queue *last = NULL; void Push_back(process); process Pop_front(void); main() { int n, q, count = 0; process pro...
[["-", 51, 2, 3, 4, 0, 105, 51, 23, 0, 22], ["+", 51, 2, 3, 4, 0, 105, 51, 23, 0, 22]]
0
352
2
#include <stdio.h> #define N 200000 typedef struct process { char name[11]; int time; } process; process P[N]; int head = 0; int bottom = 0; void push(process x) { P[head % N] = x; head++; } process pop(void) { int d; d = bottom % N; bottom++; return P[d]; } int main(int argc, char argv[]) { int n;...
#include <stdio.h> #define N 200000 typedef struct process { char name[11]; int time; } process; process P[N]; int head = 0; int bottom = 0; void push(process x) { P[head % N] = x; head++; } process pop(void) { int d; d = bottom % N; bottom++; return P[d]; } int main(int argc, char argv[]) { int n;...
[["-", 8, 9, 0, 52, 15, 23, 0, 16, 17, 60], ["+", 8, 9, 0, 52, 15, 23, 0, 16, 17, 79], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
227
3
#include <stdio.h> #include <string.h> #define N 100000 typedef struct { char name[10]; int time; } process; process Q[N]; int head; int tail; void initialize() { head = tail = 0; } int isEmpty() { return head == tail; } int isFull() { return head == (tail + 1) % N; } void enqueue(char *name, int tim) { if ...
#include <stdio.h> #include <string.h> #define N 100000 typedef struct { char name[10]; int time; } process; process Q[N]; int head; int tail; void initialize() { head = tail = 0; } int isEmpty() { return head == tail; } int isFull() { return head == (tail + 1) % N; } void enqueue(char *name, int tim) { if ...
[["-", 0, 14, 8, 9, 0, 43, 49, 84, 0, 48], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 0, 70], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 0, 73]]
0
360
4
#include <stdio.h> #define SIZE 1000 struct process { char name[10]; int time; }; struct process p[SIZE]; int head, tail; void enqueue(struct process x) { p[tail] = x; if (tail + 1 == SIZE + 1) tail = 0; else tail++; } struct process dequeue() { struct process y; y = p[head]; if (head + 1 =...
#include <stdio.h> #define SIZE 100000 struct process { char name[10]; int time; }; struct process p[SIZE]; int head, tail; void enqueue(struct process x) { p[tail] = x; if (tail + 1 == SIZE) tail = 0; else tail++; } struct process dequeue() { struct process y; y = p[head]; if (head + 1 == ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 17, 72], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13]]
0
274
6
#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct node *link; typedef struct process proc; typedef proc Item; struct process { char name[11]; int time; }; struct node { Item item; link next; }; static link head, tail; void Queueinit(int maxN) { head = NULL; } int Que...
#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct node *link; typedef struct process proc; typedef proc Item; struct process { char name[11]; int time; }; struct node { Item item; link next; }; static link head, tail; void Queueinit(int maxN) { head = NULL; } int Que...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
0
391
6