s_id string | p_id string | u_id string | date string | language string | original_language string | filename_ext string | status string | cpu_time string | memory string | code_size string | code string | error string | stdout string |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s641747631 | p02274 | u567281053 | 1458134714 | Python | Python | py | Runtime Error | 0 | 0 | 299 | import numpy
def countInversions(A, cnt):
if len(A) == 1:
return cnt
maxi = numpy.argmax(A)
cnt += len(A) - maxi - 1
del A[maxi]
return countInversions(A, cnt)
if __name__ == "__main__":
input()
A = map(int, raw_input().split())
print countInversions(A, 0) | File "/tmp/tmpo0xncdfz/tmptt9pzmbk.py", line 15
print countInversions(A, 0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s807305061 | p02274 | u567281053 | 1458135048 | Python | Python | py | Runtime Error | 10 | 6432 | 425 | def countInversions(A, cnt):
if len(A) == 1:
return cnt
maxi = argmax(A)
cnt += len(A) - maxi - 1
del A[maxi]
return countInversions(A, cnt)
def argmax(A):
max = maxi = 0
for i in range(len(A)):
if A[i] > max:
max = A[i]
maxi = i
return maxi
if __name__ == "__main__":
input()
A = map(int, raw_input().split())
print countInversions(A, 0) | File "/tmp/tmpkhnxqe77/tmpoec8iqym.py", line 21
print countInversions(A, 0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s278051251 | p02274 | u294007207 | 1458572051 | Python | Python | py | Runtime Error | 10 | 6544 | 1068 | import array
def merge_sort(A):
if len(A) <= 1:
return A, 0
mid = len(A) // 2
left, lcount = merge_sort(A[:mid])
right, rcount = merge_sort(A[mid:])
merged, count = merge(left, right)
return merged, lcount + rcount + count
def merge(left, right):
lpos = 0
rpos = 0
rcount = 0
merged = array.array('B', []) # List is too slow, so use array instead
len_left = len(left)
len_right = len(right)
while lpos < len_left and rpos < len_right:
if left[lpos] < right[rpos]:
merged.append(left[lpos])
lpos += 1
else:
merged.append(right[rpos])
rpos += 1
rcount += len(left[lpos:])
if left[lpos:]:
merged.extend(left[lpos:])
if right[rpos:]:
merged.extend(right[rpos:])
return merged, rcount
if __name__ == '__main__':
n = int(raw_input())
A = array.array('B', map(int, raw_input().split()))
sorted, count = merge_sort(A)
#print ' '.join(str(x) for x in sorted)
print count | File "/tmp/tmpi2diro_o/tmpj7z5r0z7.py", line 41
print count
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s071062685 | p02274 | u294007207 | 1458572320 | Python | Python | py | Runtime Error | 10 | 6540 | 1068 | import array
def merge_sort(A):
if len(A) <= 1:
return A, 0
mid = len(A) // 2
left, lcount = merge_sort(A[:mid])
right, rcount = merge_sort(A[mid:])
merged, count = merge(left, right)
return merged, lcount + rcount + count
def merge(left, right):
lpos = 0
rpos = 0
rcount = 0
merged = array.array('h', []) # List is too slow, so use array instead
len_left = len(left)
len_right = len(right)
while lpos < len_left and rpos < len_right:
if left[lpos] < right[rpos]:
merged.append(left[lpos])
lpos += 1
else:
merged.append(right[rpos])
rpos += 1
rcount += len(left[lpos:])
if left[lpos:]:
merged.extend(left[lpos:])
if right[rpos:]:
merged.extend(right[rpos:])
return merged, rcount
if __name__ == '__main__':
n = int(raw_input())
A = array.array('h', map(int, raw_input().split()))
sorted, count = merge_sort(A)
#print ' '.join(str(x) for x in sorted)
print count | File "/tmp/tmpv0_lztig/tmprpqe6iqg.py", line 41
print count
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s061946076 | p02274 | u963402991 | 1459479502 | Python | Python3 | py | Runtime Error | 0 | 0 | 231 | from collections import deque
n = int(input())
A = deque(map(int, input().split()))
num = list(sorted(A, reverse=True))
count = 0
for i in range(n - 1):
count += len(A) - 1 - A.index(num[i])
A.remove(num[i])
print(count) | Traceback (most recent call last):
File "/tmp/tmphulwu309/tmpow852dq9.py", line 3, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s854815774 | p02274 | u963402991 | 1459480359 | Python | Python3 | py | Runtime Error | 0 | 0 | 230 | from collections import deque
n = int(input())
A = deque(map(int, input().split()))
num = list(sorted(A, reverse=True))
count = 0
for i in range(n - 1):
count += len(A) - 1 - A.index(num[i])
A.remove(num[i])
print(count) | Traceback (most recent call last):
File "/tmp/tmp___4rqu0/tmptf26u74g.py", line 2, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s754508052 | p02274 | u130979865 | 1459839962 | Python | Python | py | Runtime Error | 0 | 0 | 195 | # -*- coding: utf-8 -*-
n = int(raw_input())
A = map(int, raw_input().split())
count = 0
for i in range(n):
for j = in range(i, n):
if A[i] > A[j]:
count += 1
print count | File "/tmp/tmpwn0fuh_5/tmpr22iu2vd.py", line 7
for j = in range(i, n):
^
SyntaxError: invalid syntax
| |
s562236116 | p02274 | u569960318 | 1465803862 | Python | Python3 | py | Runtime Error | 40 | 7724 | 246 | def invNum(A):
if len(A)==1: return 0
cnt = 0
for i in range(1,len(A)):
if A[0] > A[i]: cnt += 1
return cnt + invNum(A[1:])
if __name__=='__main__':
n = int(input())
print(invNum(list(map(int,input().split())))) | Traceback (most recent call last):
File "/tmp/tmpyet2t8we/tmpkevprh3j.py", line 10, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s176368175 | p02274 | u742013327 | 1477887665 | Python | Python3 | py | Runtime Error | 30 | 7700 | 839 | def bubble_sort_revision(target_list):
list_length = len(target_list)
flag = True
change_count = 0
for top_index in range(1,list_length):
for i in range(top_index, list_length)[::-1]:
if target_list[i] < target_list[i - 1] and target_list[top_index] >= target_list[i]:
tmp = target_list[i]
target_list[i] = target_list[i - 1]
target_list[i - 1] = tmp
change_count += 1
return change_count
def solve(n, target_list):
a = [0 for i in range(n + 1)]
ans = 0
for i in range(n):
ans += i - sum(a[:target_list[i]])
a[target_list[i]] += 1
return ans
if __name__ == "__main__":
l = int(input())
target_list = [int(i) for i in input().split()]
print(solve(l, target_list)) | Traceback (most recent call last):
File "/tmp/tmpuqdo4zro/tmp8soyb89s.py", line 26, in <module>
l = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s049440295 | p02274 | u130834228 | 1491372398 | Python | Python3 | py | Runtime Error | 0 | 0 | 162 | n = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(n):
for j in range(i+1, n):
if A[i] > A[j]:
cnt++
print(cnt) | File "/tmp/tmpdvjt0mf_/tmpslqvvaar.py", line 8
cnt++
^
SyntaxError: invalid syntax
| |
s982427589 | p02274 | u130834228 | 1492065174 | Python | Python3 | py | Runtime Error | 0 | 0 | 887 | def merge(A, left, mid, right):
n1 = mid-left
n2 = right-mid
#L = [0 for i in range(n1+1)]
#R = [0 for i in range(n2+1)]
#for i in range(n1):
# L[i] = A[left+i]
#for i in range(n2):
# R[i] = A[mid+i]
L = A[left:mid]
R = A[mid:right]
L.append(float('inf'))
R.append(float('inf'))
i = 0
j = 0
global cnt
for k in range(left, right):
if L[i] <= R[j]:
A[k] = L[i]
i = i+1
else:
A[k] = R[j]
j = j+1
cnt += l-i
def mergeSort(A, left, right):
if left+1 < right:
mid = (left+right) // 2
mergeSort(A, left, mid)
mergeSort(A, mid, right)
merge(A, left, mid, right)
else:
return 0
n = input()
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, len(A))
#print(*A)
print(str(cnt)) | Traceback (most recent call last):
File "/tmp/tmpshkkmu94/tmpzz60mxhj.py", line 38, in <module>
n = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s205424197 | p02274 | u193453446 | 1501553789 | Python | Python3 | py | Runtime Error | 0 | 0 | 383 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
""" ????????? """
num = int(input().strip())
A = list(map(int,input().split()))
cnt = 0
for i in range(num-1):
for j in range(i,num):
if i > j:
cnt++
if cnt % 2 == 0:
cnt += 1
else:
cnt -= 1
print(cnt)
if __name__ == '__main__':
main() | File "/tmp/tmpct3xog4k/tmpwxf430mi.py", line 12
cnt++
^
SyntaxError: invalid syntax
| |
s575713100 | p02274 | u426534722 | 1516976288 | Python | Python3 | py | Runtime Error | 0 | 0 | 130 | N = int(input())
A = tuple(map(int, input().split()))
print(len(1 for i in range(N - 1) for j in range(i + 1, N) if A[i] > A[j]))
| Traceback (most recent call last):
File "/tmp/tmpti4qw1fa/tmpipf_mpij.py", line 1, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s960564865 | p02274 | u464859367 | 1525321775 | Python | Python3 | py | Runtime Error | 0 | 0 | 1873 | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ALDS1_5_B
{
class Program
{
static long cnt = 0;
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] S = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
// rightの初期値は配列の要素数
MergeSort(S, 0, n);
Console.WriteLine(cnt);
}
static void Merge(int[] A, int left, int mid, int right)
{
int n1 = mid - left;
int n2 = right - mid;
// 左右それぞれ一つ多く要素を作る
int[] L = new int[n1 + 1];
int[] R = new int[n2 + 1];
// もとの配列を左右に分ける
for (int i = 0; i < n1; i++)
{
L[i] = A[left + i];
}
for (int i = 0; i < n2; i++)
{
R[i] = A[mid + 1];
}
// 無限みたいな
L[n1] = int.MaxValue;
R[n2] = int.MaxValue;
int m = 0, j = 0;
for (int k = left; k < right; k++)
{
if (L[m] <= R[j])
{
A[k] = L[m];
m++;
cnt += j;
}
else
{
A[k] = R[j];
j++;
}
}
}
static void MergeSort(int[] A, int left, int right)
{
if (left + 1 < right)
{
int mid = (left + right) / 2;
MergeSort(A, left, mid);
MergeSort(A, mid, right);
Merge(A, left, mid, right);
}
}
}
}
| File "/tmp/tmp2_yhymj3/tmpeauzgaqz.py", line 1
using System;
^^^^^^
SyntaxError: invalid syntax
| |
s994874665 | p02274 | u011621222 | 1526041484 | Python | Python3 | py | Runtime Error | 0 | 0 | 953 | MAX = 500000;
maxnum = 1000000010;
cnt=0
def Merge_sort(A):
def merge(A,left,mid,right):
global cnt
t1=array.array('L',[])
t2=array.array('L',[])
for i in range(left,mid):
t1.append(A[i])
for i in range(mid,right):
t2.append(A[i])
t1.append(maxnum)
t2.append(maxnum)
i=0
j=0
k=0
nl=mid-left
for k in range(left,right):
if t1[i]<=t2[j]:
A[k]=t1[i]
i+=1
else:
A[k]=t2[j]
j+=1
cnt+=nl-i
def mergesort(A,left,right):
if right-left <=1:
return
mid = (left+right) // 2
mergesort(A,left,mid)
mergesort(A,mid,right)
merge(A,left,mid,right)
mergesort(A,0,len(A))
n=int(input())
A=[int(x) for x in input().split()]
Merge_sort(A)
print(cnt)
| Traceback (most recent call last):
File "/tmp/tmp4iqktw16/tmpbl_ehwj3.py", line 45, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s800669911 | p02274 | u564105430 | 1527154562 | Python | Python3 | py | Runtime Error | 0 | 0 | 368 | def shakerSort(A):
cnt=0
left=0
right=len(A)-1
while left<right:
for i in range(left,right):
if A[i]>A[i+1]:
A[i],A[i+1]=A[i+1],A[i]
sh=i
cnt+=1
right=sh
for j in range(right,left,-1):
if A[j]<A[j-1]:
A[j],A[j-1]=A[j-1],A[j]
sh=j
cnt+=1
left=sh
return cnt
n=int(input())
A=list(map(int,input().split()))
print(shakerSort(A)
| File "/tmp/tmp6nkxwlbj/tmp16zggm9e.py", line 22
print(shakerSort(A)
^
SyntaxError: '(' was never closed
| |
s776178404 | p02274 | u564105430 | 1527154576 | Python | Python3 | py | Runtime Error | 20 | 5600 | 369 | def shakerSort(A):
cnt=0
left=0
right=len(A)-1
while left<right:
for i in range(left,right):
if A[i]>A[i+1]:
A[i],A[i+1]=A[i+1],A[i]
sh=i
cnt+=1
right=sh
for j in range(right,left,-1):
if A[j]<A[j-1]:
A[j],A[j-1]=A[j-1],A[j]
sh=j
cnt+=1
left=sh
return cnt
n=int(input())
A=list(map(int,input().split()))
print(shakerSort(A))
| Traceback (most recent call last):
File "/tmp/tmpcafs5wk2/tmpeqcq9v2x.py", line 20, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s613079792 | p02274 | u782850499 | 1527826622 | Python | Python3 | py | Runtime Error | 0 | 0 | 716 | cnt = 0
def merge(A,left,mid,right):
global cnt
n1 = mid - left
n2 = right - mid
L = [A[i] for i in range(left, mid)]
R = [A[i] for i in range(mid, right)]
L.append(float("inf"))
R.append(float("inf"))
i = 0
j = 0
for k in range(left, right):
if L[i] <= R[j]:
A[k] = L[i]
i += 1
else:
cnt += n1 - i
A[k] = R[j]
j += 1
def mergeSort(A,left,right):
if left + 1 < right:
mid = (left+right) // 2
mergeSort(A,left,mid)
mergeSort(A,mid,right)
merge(A,left,mid,right)
input()
a = list(map(int, input().split()))
mergeSort(a, 0, len(a))
return cnt
| File "/tmp/tmpdr029vr0/tmpbqy571tb.py", line 32
return cnt
^^^^^^^^^^
SyntaxError: 'return' outside function
| |
s040864485 | p02274 | u007270338 | 1528174586 | Python | Python3 | py | Runtime Error | 650 | 16476 | 631 | #coding:utf-8
n = int(input())
A = list(map(int, input().split()))
def Merge(A, left, mid, right):
L = A[left:mid]
R = A[mid:right]
L.append(510000)
R.append(510000)
i,j = 0,0
global cnt
for k in range(left,right):
if L[i] <= R[j]:
A[k] = L[i]
i += 1
else:
A[k] = R[j]
j += 1
cnt += mid - left - i
def MergeSort(A, left, right):
if left+1 < right:
mid = (left + right)//2
MergeSort(A, left, mid)
MergeSort(A, mid, right)
Merge(A, left, mid, right)
cnt = 0
MergeSort(A, 0, n)
print(cnt)
| Traceback (most recent call last):
File "/tmp/tmpgurwc372/tmp1btcbu1q.py", line 3, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s865466949 | p02275 | u657361950 | 1531377589 | Python | Python3 | py | Runtime Error | 0 | 0 | 960 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(reader.readLine());
String[] strArray = reader.readLine().split(" ");
int[] a = new int[n];
int[] c = new int[10000];
int k = Integer.MIN_VALUE;
for (int i = 0; i < n; i++) {
a[i] = Integer.parseInt(strArray[i]);
k = Math.max(k, a[i]);
c[a[i]]++;
}
int[] b = new int[n];
countingSort(a, b, c, k);
System.out.print(b[0]);
for (int i = 1; i < n; i++) {
System.out.print(" " + b[i]);
}
System.out.println("");
}
private static void countingSort(int[] a, int[] b, int[] c, int k) {
for (int i = 1; i <= k; i++) {
c[i] = c[i] + c[i - 1];
}
for (int i = a.length - 1; i >= 0; i--) {
b[c[a[i]] - 1] = a[i];
c[a[i]]--;
}
}
}
| File "/tmp/tmpt2loz1ao/tmpvu0kbiv8.py", line 5
public class Main {
^^^^^
SyntaxError: invalid syntax
| |
s675647583 | p02275 | u153665391 | 1532162564 | Python | Python3 | py | Runtime Error | 0 | 0 | 416 | def counting_sort(MAX):
C = [0 for _ in range(MAX+1)]
for i in range(N):
C[A[i]] += 1
for i in range(1, MAX+1):
C[i] = C[i] + C[i-1]
for i in range(N-1, -1, -1):
C[A[i]] -= 1
B[C[A[i]]] = A[i]
N = int(input())
A = list(map(int, input().split()))
MAX = 0
for n in A:
if MAX < n:
MAX = n
B = [0 for _ in range(N)]
counting_sort(MAX)
print(" ".join(B))
| Traceback (most recent call last):
File "/tmp/tmpaixkfawv/tmpd8__atrq.py", line 14, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s870515981 | p02275 | u487861672 | 1534940227 | Python | Python3 | py | Runtime Error | 20 | 5600 | 351 | def counting_sort(A, k):
B = [0] * len(A)
C = [0] * k
for a in A:
C[a] += 1
for i in range(1, k):
C[i] += C[i - 1]
for a in reversed(A):
B[C[a] - 1] = a
C[a] -= 1
return B
def main():
n = int(input())
A = [int(x) for x in input().split()]
print(*counting_sort(A, 11))
main()
| Traceback (most recent call last):
File "/tmp/tmponcwgcam/tmpb1i5mtcs.py", line 24, in <module>
main()
File "/tmp/tmponcwgcam/tmpb1i5mtcs.py", line 19, in main
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s894993784 | p02275 | u803657704 | 1545368733 | Python | Python3 | py | Runtime Error | 20 | 5600 | 547 | def CountingSort(A, B, k):
C = [0] * (k+1)
#C[i] に i の出現数を記録する
for j in range(0,k):
C[A[j]]+=1
#print("C ",j,C[:k+1])
#C[i] に i 以下の数の出現数を記録する
for i in range(1,k+1):
C[i] = C[i] + C[i-1]
#print("C' ",j,C[:k+1])
for j in range(k-1,-1,-1):
B[C[A[j]]] = A[j]
C[A[j]]-=1
#print(j,A[j],C[A[j]],B[C[A[j]]],B,C)
n = int(input())
A = list(map(int,input().split()))
B = [0] * (n+1)
CountingSort(A,B,n)
print(' '.join(map(str,B[1:])))
| Traceback (most recent call last):
File "/tmp/tmpdjzm73yt/tmp6qivipxl.py", line 16, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s328622135 | p02275 | u237270455 | 1545369825 | Python | Python3 | py | Runtime Error | 20 | 6500 | 451 | n = int(input())
temp = [int(i) for i in input().split()]
A = [None for i in range(10000)]
B = [0 for i in range(n)]
k = 0
for i in range(n):
A[i] = temp[i]
if(A[i]>k):
k=A[i]
def cntSort(A, B, k):
C = [0 for i in range(k)]
for j in range(0, n):
C[A[j]] += 1
for i in range(1, k):
C[i] += C[i-1]
for i in range(n-1, -1, -1):
B[C[A[i]]-1] = A[i]
C[A[i]] -= 1
cntSort(A, B, k+1)
print(*B)
| Traceback (most recent call last):
File "/tmp/tmp54m9a72z/tmp8ytgga8f.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s504494930 | p02275 | u237270455 | 1545369980 | Python | Python3 | py | Runtime Error | 50 | 7976 | 483 | n = int(input())
temp = [int(i) for i in input().split()]
A = [None for i in range(200000)]
B = [0 for i in range(n)]
k = 0
for i in range(n):
A[i] = temp[i]
if(A[i]>k):
k=A[i]
if(k>10000):
break
def cntSort(A, B, k):
C = [0 for i in range(k)]
for j in range(0, n):
C[A[j]] += 1
for i in range(1, k):
C[i] += C[i-1]
for i in range(n-1, -1, -1):
B[C[A[i]]-1] = A[i]
C[A[i]] -= 1
cntSort(A, B, k+1)
print(*B)
| Traceback (most recent call last):
File "/tmp/tmp77807odd/tmpqyzkic7l.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s151307829 | p02275 | u237270455 | 1545370052 | Python | Python3 | py | Runtime Error | 70 | 7976 | 483 | n = int(input())
temp = [int(i) for i in input().split()]
A = [None for i in range(200001)]
B = [0 for i in range(n)]
k = 0
for i in range(n):
A[i] = temp[i]
if(A[i]>k):
k=A[i]
if(k>10000):
break
def cntSort(A, B, k):
C = [0 for i in range(k)]
for j in range(0, n):
C[A[j]] += 1
for i in range(1, k):
C[i] += C[i-1]
for i in range(n-1, -1, -1):
B[C[A[i]]-1] = A[i]
C[A[i]] -= 1
cntSort(A, B, k+1)
print(*B)
| Traceback (most recent call last):
File "/tmp/tmpp2rkusgj/tmpqpf06qtp.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s183824544 | p02275 | u237270455 | 1545370247 | Python | Python3 | py | Runtime Error | 40 | 8076 | 549 | n = int(input())
temp = [int(i) for i in input().split()]
A = [None for i in range(200001)]
B = [0 for i in range(n)]
k = 0
for i in range(n):
try:
A[i] = temp[i]
if(A[i]>k):
k=A[i]
if(k>10000):
break
except IndexError:
break
def cntSort(A, B, k):
C = [0 for i in range(k)]
for j in range(0, n):
C[A[j]] += 1
for i in range(1, k):
C[i] += C[i-1]
for i in range(n-1, -1, -1):
B[C[A[i]]-1] = A[i]
C[A[i]] -= 1
cntSort(A, B, k+1)
print(*B)
| Traceback (most recent call last):
File "/tmp/tmpijyxs4qw/tmp6zkn_9pu.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s528510020 | p02275 | u237270455 | 1545370566 | Python | Python3 | py | Runtime Error | 40 | 8072 | 573 | n = int(input())
temp = [int(i) for i in input().split()]
A = [None for i in range(200001)]
B = [0 for i in range(n)]
k = 0
for i in range(n):
try:
A[i] = temp[i]
if(A[i]>k):
k=A[i]
if(k>10000):
break
except IndexError:
n = len(A[i])-1
break
def cntSort(A, B, k):
C = [0 for i in range(k)]
for j in range(0, n):
C[A[j]] += 1
for i in range(1, k):
C[i] += C[i-1]
for i in range(n-1, -1, -1):
B[C[A[i]]-1] = A[i]
C[A[i]] -= 1
cntSort(A, B, k+1)
print(*B)
| Traceback (most recent call last):
File "/tmp/tmp2tvjiin3/tmp_gvd_sp4.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s820381094 | p02275 | u237270455 | 1545371032 | Python | Python3 | py | Runtime Error | 40 | 8072 | 565 | n = int(input())
temp = [int(i) for i in input().split()]
A = [None for i in range(200000)]
B = [0 for i in range(n)]
k = 0
for i in range(n):
try:
A[i] = temp[i]
if(A[i]>k):
k=A[i]
if(k>10000):
break
except IndexError:
n = n-1
break
def cntSort(A, B, k):
C = [0 for i in range(k)]
for j in range(0, n):
C[A[j]] += 1
for i in range(1, k):
C[i] += C[i-1]
for i in range(n-1, -1, -1):
B[C[A[i]]-1] = A[i]
C[A[i]] -= 1
cntSort(A, B, k+1)
print(*B)
| Traceback (most recent call last):
File "/tmp/tmpdk8tjz2o/tmp6jfovn21.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s687367983 | p02275 | u237270455 | 1545371202 | Python | Python3 | py | Runtime Error | 30 | 8076 | 627 | n = int(input())
temp = [int(i) for i in input().split()]
A = [None for i in range(200000)]
B = [0 for i in range(n)]
k = 0
for i in range(n):
try:
A[i] = temp[i]
if(A[i]>k):
k=A[i]
if(k>10000):
break
except IndexError:
n = n-1
break
def cntSort(A, B, k):
C = [0 for i in range(k)]
for j in range(0, n):
try:
C[A[j]] += 1
except IndexError:
break
for i in range(1, k):
C[i] += C[i-1]
for i in range(n-1, -1, -1):
B[C[A[i]]-1] = A[i]
C[A[i]] -= 1
cntSort(A, B, k+1)
print(*B)
| Traceback (most recent call last):
File "/tmp/tmp5mxn790b/tmpli8skl99.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s046534502 | p02275 | u363774867 | 1556206867 | Python | Python3 | py | Runtime Error | 20 | 5604 | 417 | def countingsort(a,k):
c=[0]*(k+1)
n=len(a)
for i in a:
c[i]+=1
for i in range(1,k+1):
c[i]=c[i]+c[i-1]
b=[0]*n
for i in range(n-1,-1,-1):
b[c[a[i]]-1]=a[i]
c[a[i]]-=1
return b
q=int(input())
a=list(map(int,input().split()))
ret=countingsort(a,q)
for i in range(len(ret)):
if i!=len(ret)-1:
print(ret[i],end=" ")
else:
print(ret[i])
| Traceback (most recent call last):
File "/tmp/tmp8a58cnx4/tmp5o5tk97e.py", line 13, in <module>
q=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s046257173 | p02275 | u363774867 | 1556206983 | Python | Python3 | py | Runtime Error | 0 | 0 | 412 | def countingsort(a,k):
c=[0]*(k+1)
n=len(a)
for i in a:
c[i]+=1
for i in range(1,k+1):
c[i]=c[i]+c[i-1]
b=[0]*n
for i in range(n-1,-1,-1):
b[c[a[i]]-1]=a[i]
c[a[i]]-=1
return b
o=int(input())
a=list(map(int,input().split()))
q=max(a)
ret=countingsort(a,q)
for i in range(n):
if i!=n-1:
print(ret[i],end=" ")
else:
print(ret[i])
| Traceback (most recent call last):
File "/tmp/tmpmz0ukvki/tmpivpa7d9r.py", line 13, in <module>
o=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s241325775 | p02275 | u805716376 | 1556765891 | Python | Python3 | py | Runtime Error | 0 | 0 | 321 | #計数ソート
n = int(input())
a = list(map(int, input().split()))
def countSort(a):
N = max(a)
c = [0]*(N+2)
b = [0]*len(a)
for i in a:
c[i] += 1
for i in range(1,len(c)):
c[i] += c[i-1]
for i in a:
b[c[i]-1] = i
c[i] -= 1
print(b)
countSort(*a)
| Traceback (most recent call last):
File "/tmp/tmp3nw38suc/tmpob0eqibk.py", line 2, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s830923495 | p02275 | u548252256 | 1559567106 | Python | Python3 | py | Runtime Error | 20 | 5604 | 488 | def CountingSort(A,B,num):
C = [0 for _ in range(num)]
#C[i]にiの出現回数を記録する
for i in A:
C[i] += 1
#C[i]にi以下の数の出現数を記録する =>累積度数分布を出力
k = max(A)
for j in range(k+1):
C[j] += C[j-1]
for h in range(k+1):
B[C[A[h]]-1] = A[h]
C[A[h]] -= 1
if __name__ == '__main__':
num = int(input())
A = [int(i) for i in input().split()]
B = [0 for _ in range(num)]
CountingSort(A,B,num)
print(" ".join(map(str,B)))
| Traceback (most recent call last):
File "/tmp/tmp37pewwq0/tmpt8g7ivbz.py", line 20, in <module>
num = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s572567553 | p02275 | u548252256 | 1559569777 | Python | Python3 | py | Runtime Error | 20 | 5608 | 509 | def CountingSort(A,B,num):
C = [0 for _ in range(num+1)]
#C[i]にiの出現回数を記録する
for i in A:
C[i] += 1
#C[i]にi以下の数の出現数を記録する =>累積度数分布を出力
k = max(A)
for j in range(1,k+1):
C[j] += C[j-1]
for h in range(num-1,-1,-1):
B[C[A[h]]-1] = A[h]
C[A[h]] -= 1
if __name__ == '__main__':
num = int(input())
A = [int(i) for i in input().split()]
B = [0 for _ in range(num+1)]
CountingSort(A,B,num)
B.pop()
print(" ".join(map(str,B)))
| Traceback (most recent call last):
File "/tmp/tmpx8faj2_8/tmppan8jt3w.py", line 18, in <module>
num = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s021027269 | p02275 | u963402991 | 1459733596 | Python | Python3 | py | Runtime Error | 0 | 0 | 496 |
def counting_sort(A, k):
B = [0 for i in range(len(A))]
C = [0 for i in range(0, k + 1)]
# C[i]???i???????????°????¨??????????
for j in range(1, n):
C[A[j]] += 1
# C[i]???i??\????????°???????????°????¨??????????
for i in range(1, k + 1):
C[i] += C[i - 1]
for j in reversed(range(1, n)):
B[C[A[j]]] = A[j]
C[A[j]] -= 1
return B
n = int(input())
A = list(map(int, input().split()))
k = max(A)
print(counting_sort(A, B, k)) | Traceback (most recent call last):
File "/tmp/tmp1kdw7_hn/tmpmczh3r6k.py", line 19, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s102288708 | p02275 | u130979865 | 1459916711 | Python | Python | py | Runtime Error | 10 | 6864 | 480 | # -*- coding: utf-8 -*-
def countSort(A, m):
count = [0]*(m+1)
n = len(A)
B = [0]*m
j = 0
for i in range(n):
count[A[i]] += 1
for i in range(1, m):
count[i] += count[i-1]
for i in range(n-1, -1, -1):
j = count[A[i]]
B[j] = A[i]
count[A[i]] = j-1
for i in range(n):
A[i] = B[i+1]
return A
n = int(raw_input())
A = map(int, raw_input().split())
B = countSort(A, 10000)
print " ".join(map(str, B)) | File "/tmp/tmpmzcadedh/tmpzk_t51qy.py", line 23
print " ".join(map(str, B))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s270117966 | p02275 | u130979865 | 1459916833 | Python | Python | py | Runtime Error | 40 | 22500 | 486 | # -*- coding: utf-8 -*-
def countSort(A, m):
count = [0]*(m+1)
n = len(A)
B = [0]*2000000
j = 0
for i in range(n):
count[A[i]] += 1
for i in range(1, m):
count[i] += count[i-1]
for i in range(n-1, -1, -1):
j = count[A[i]]
B[j] = A[i]
count[A[i]] = j-1
for i in range(n):
A[i] = B[i+1]
return A
n = int(raw_input())
A = map(int, raw_input().split())
B = countSort(A, 10000)
print " ".join(map(str, B)) | File "/tmp/tmpe2ey5370/tmpy1we963_.py", line 23
print " ".join(map(str, B))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s246946181 | p02275 | u742013327 | 1478597896 | Python | Python3 | py | Runtime Error | 0 | 0 | 566 |
def counting_sort(target_list):
counter = [0 for i in range(10000)]
for n in target_list:
counter[n] += 1
for i in range(1,10000):
counter[i] = counter[i] + counter[i-1]
result = [0 for i in range(len(target_list))]
for n in target_list[::-1]:
result[counter[n] - 1] = n
counter[n] -= 1
return result
if __name__ == "__main__":
n_list = int(input())
target_list = [int(s) for s in input().split()]
sorted_list = counting_sort(target_list)
print(" ".join([int(s) for s in sorted_list])) | Traceback (most recent call last):
File "/tmp/tmpl6ze8kfc/tmpna8esnmp.py", line 18, in <module>
n_list = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s039396554 | p02275 | u022407960 | 1478861863 | Python | Python3 | py | Runtime Error | 30 | 8776 | 699 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
def counting_sort(A, k):
B = [0] * k
C = [0] * k
for j in range(array_length):
C[A[j]] += 1
# print('1', C[:array_length])
for i in range(1, k):
C[i] += C[i - 1]
# print('2', C[:array_length])
for m in range(array_length - 1, -1, -1):
B[C[A[m]]] = A[m]
C[A[m]] -= 1
return B[1:array_length + 1]
if __name__ == '__main__':
_input = sys.stdin.readlines()
array_length = int(_input[0])
array = list(map(int, _input[1].split()))
assert len(array) == array_length
MAX_ELEM = int(1e4 + 1)
result = counting_sort(A=array, k=MAX_ELEM)
print(*result) | Traceback (most recent call last):
File "/tmp/tmp2h1h0beq/tmpdll9ah99.py", line 28, in <module>
array_length = int(_input[0])
~~~~~~^^^
IndexError: list index out of range
| |
s901136393 | p02275 | u022407960 | 1478862060 | Python | Python3 | py | Runtime Error | 20 | 8716 | 699 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
def counting_sort(A, k):
B = [0] * k
C = [0] * k
for j in range(array_length):
C[A[j]] += 1
# print('1', C[:array_length])
for i in range(1, k):
C[i] += C[i - 1]
# print('2', C[:array_length])
for m in range(array_length - 1, -1, -1):
B[C[A[m]]] = A[m]
C[A[m]] -= 1
return B[1:array_length + 1]
if __name__ == '__main__':
_input = sys.stdin.readlines()
array_length = int(_input[0])
array = list(map(int, _input[1].split()))
assert len(array) == array_length
MAX_ELEM = int(1e4 + 1)
result = counting_sort(A=array, k=MAX_ELEM)
print(*result) | Traceback (most recent call last):
File "/tmp/tmpz7vjg6tl/tmpquab9buj.py", line 28, in <module>
array_length = int(_input[0])
~~~~~~^^^
IndexError: list index out of range
| |
s653995451 | p02275 | u564398841 | 1486275720 | Python | Python3 | py | Runtime Error | 60 | 12644 | 447 | def CountingSort(A, k):
C = [0] * k
B = C[:]
for a in A:
C[a] += 1
for i in range(1, len(C)):
C[i] += C[i - 1]
for i in range(len(A) - 1, -1, -1):
B[C[A[i]]] = A[i]
C[A[i]] -= 1
return B
if __name__ == '__main__':
N = int(input())
A = [int(i) for i in input().strip().split()]
sorted_A = CountingSort(A, int(10E4))
print(' '.join([str(a) for a in sorted_A[1:len(A) + 1]])) | Traceback (most recent call last):
File "/tmp/tmp3kn8fvgn/tmp6zlenne3.py", line 16, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s526485922 | p02275 | u564398841 | 1486275791 | Python | Python3 | py | Runtime Error | 80 | 17428 | 446 | def CountingSort(A, k):
C = [0] * k
B = C[:]
for a in A:
C[a] += 1
for i in range(1, len(C)):
C[i] += C[i - 1]
for i in range(len(A) - 1, -1, -1):
B[C[A[i]]] = A[i]
C[A[i]] -= 1
return B
if __name__ == '__main__':
N = int(input())
A = [int(i) for i in input().strip().split()]
sorted_A = CountingSort(A, int(20E4))
print(' '.join([str(a) for a in sorted_A[1:len(A) + 1]])) | Traceback (most recent call last):
File "/tmp/tmptjg0y9gh/tmpljoi6bac.py", line 15, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s354247541 | p02275 | u564398841 | 1486275857 | Python | Python3 | py | Runtime Error | 0 | 0 | 448 | def CountingSort(A, k):
C = [0] * k
B = C[:]
for a in A:
C[a] += 1
for i in range(1, len(C)):
C[i] += C[i - 1]
for i in range(len(A) - 1, -1, -1):
B[C[A[i]]] = A[i]
C[A[i]] -= 1
return B
if __name__ == '__main__':
N = int(input())
A = [int(i) for i in input().strip().split()]
sorted_A = CountingSort(A, int(3E10))
print(' '.join([str(a) for a in sorted_A[1:len(A) + 1]])) | Traceback (most recent call last):
File "/tmp/tmp2mb9milp/tmpo9fx9csp.py", line 17, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s063138590 | p02275 | u564398841 | 1486275876 | Python | Python3 | py | Runtime Error | 0 | 0 | 492 | def CountingSort(A, k):
C = [0] * k
B = C[:]
for a in A:
C[a] += 1
for i in range(1, len(C)):
C[i] += C[i - 1]
for i in range(len(A) - 1, -1, -1):
B[C[A[i]]] = A[i]
C[A[i]] -= 1
return B
fin = open('sample.txt')
input = fin.readline
if __name__ == '__main__':
N = int(input())
A = [int(i) for i in input().strip().split()]
sorted_A = CountingSort(A, int(3E6))
print(' '.join([str(a) for a in sorted_A[1:len(A) + 1]])) | Traceback (most recent call last):
File "/tmp/tmp57116_7c/tmpyjxr_14n.py", line 14, in <module>
fin = open('sample.txt')
^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'sample.txt'
| |
s949611255 | p02275 | u539803218 | 1496291586 | Python | Python3 | py | Runtime Error | 20 | 7548 | 463 | def counting_sort(array, maxval):
m = maxval + 1
count = [0] * (m)
for a in array:
count[a] += 1
i = 0
for a in range(m):
for c in range(count[a]):
array[i] = a
i += 1
return array
if __name__ == '__main__':
N = int(input())
l = list(map(int, input().split()))
a = 0
li = counting_sort(l, N)
for a in range(N-1):
print(li[a], end=" ")
print(li[N-1]) | Traceback (most recent call last):
File "/tmp/tmpr7tyjmmj/tmpyj2nzbiz.py", line 14, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s094813552 | p02275 | u091533407 | 1499064044 | Python | Python3 | py | Runtime Error | 0 | 0 | 430 | def CountingSort(A, B, k):
C = [0 for i in range(k+2)]
for j in range(n):
C[A[j]] += 1
for i in range(k+1):
C[i] += C[i-1]
for j in range(n-1, -1, -1):
B[C[A[j]]-1] = A[j]
C[A[j]] -= 1
if __name__=="__main__":
n = int(input())
D = list(map(int, input().split()))
l = max(D)
E = D[:]
CountingSort(D, E, l)
print(" ".join(map, str(E)))) | File "/tmp/tmpadoktw4f/tmporsg7_8f.py", line 20
print(" ".join(map, str(E))))
^
SyntaxError: unmatched ')'
| |
s380206750 | p02275 | u548155360 | 1512315316 | Python | Python3 | py | Runtime Error | 20 | 6304 | 693 | # coding=utf-8
def counting_sort(input_list: list, upper: int) -> list:
number = len(input_list)
# noinspection PyUnusedLocal
b = [0 for i in range(number+1)]
# noinspection PyUnusedLocal
counter_list = [0 for i in range(upper+1)]
for j in input_list:
counter_list[j] += 1
for i in range(k+1):
counter_list[i] += counter_list[i-1]
for j in range(number):
b[counter_list[input_list[j]]] = input_list[j]
counter_list[input_list[j]] -= 1
return b
if __name__ == '__main__':
n = int(input())
a = list(map(int, input().split()))
k = 100
a = counting_sort(a, k)
a.pop(0)
print(' '.join(map(str, a))) | Traceback (most recent call last):
File "/tmp/tmpv9oc1gsz/tmpclx38p8b.py", line 24, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s033489758 | p02275 | u146816547 | 1512651854 | Python | Python | py | Runtime Error | 0 | 0 | 372 | def counting_sort(A, B, k):
C = [0 for _ in xrange(k+1)]
for a in A:
C[a] += 1
for i in xrange(k):
C[i] = C[i] + C[i-1]
for i in xrange(n-1, -1, -1):
B[C[A[i]]-1] = A[i]
C[A[i]] -= 1
n = int(raw_input())
A = map(int, raw_input().split())
B = [0 for _ in xrange(n)]
counting_sort(A, B, 10000)
print " ".join(map(str, B) | File "/tmp/tmprqbmh7_y/tmpouju013x.py", line 20
print " ".join(map(str, B)
^
SyntaxError: '(' was never closed
| |
s418049986 | p02275 | u613534067 | 1521105051 | Python | Python3 | py | Runtime Error | 20 | 5604 | 427 | def counting_sort(A, k):
C = [0 for i in range(k)]
# C[i]にiの出現数を記録する
for l in A:
C[l] += 1
# C[i]にi以下の数の出現数を記録する
for i in range(1, k):
C[i] = C[i] + C[i-1]
B = [None for i in range(len(A))]
for l in A[::-1]:
B[C[l]-1] = l
C[l] -= 1
return B
input()
a = list(map(int, input().split()))
b = counting_sort(a, 10)
print(*b)
| Traceback (most recent call last):
File "/tmp/tmpqnxxh9x9/tmpacc9gb7w.py", line 17, in <module>
input()
EOFError: EOF when reading a line
| |
s612826947 | p02275 | u912143677 | 1521769986 | Python | Python3 | py | Runtime Error | 0 | 0 | 368 | n = int(input())
a = list(map(int, input().split()))
def countingsort(a, k):
c = [0 for i in range(k)]
b = [0 for i in range(n)]
for j in range(n):
c[a[j]] += 1
for i in range(k):
c[i+1] += c[i]
for j in reversed(range(n)):
b[c[a[j]]] = a[j]
c[a[j]] -= 1
return b
b = countingsort(a, 10001)
print(*b)
| Traceback (most recent call last):
File "/tmp/tmpp3h2ju7d/tmpleujm3w7.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s629230074 | p02275 | u126478680 | 1525368415 | Python | Python3 | py | Runtime Error | 20 | 5604 | 410 | def counting_sort(A, k):
n = len(A)
B = [0 for i in range(n)]
C = [0 for i in range(k+1)]
for j in range(n):
C[A[j]] += 1
for i in range(1, k):
C[i] = C[i] + C[i-1]
for j in range(n-1, -1, -1):
B[C[A[j]]-1] = A[j]
C[A[j]] -= 1
return B
n = int(input())
A = list(map(int, input().split(' ')))
B = counting_sort(A, 6)
print(' '.join(map(str, B)))
| Traceback (most recent call last):
File "/tmp/tmptjwr9t0s/tmp0w1m8tua.py", line 18, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s312454040 | p02275 | u938045879 | 1527411402 | Python | Python3 | py | Runtime Error | 20 | 5600 | 414 | n = int(input())
s = list(map(int, input().split()))
k = len(set(s))
c = [0 for i in range(k+1)]
def counting_sort(a, k):
global c
b = [0 for i in range(len(a)+1)]
for i in range(n):
c[a[i]] += 1
for i in range(1,k+1):
c[i] = c[i] + c[i - 1]
for i in reversed(range(n)):
b[c[a[i]]] = a[i]
c[a[i]] -= 1
return b
res = counting_sort(s, k)[1:n+1]
print(*res)
| Traceback (most recent call last):
File "/tmp/tmp78j9iezc/tmpwecul_gv.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s788126510 | p02275 | u007270338 | 1528125339 | Python | Python3 | py | Runtime Error | 20 | 6724 | 386 | #coding:utf-8
n = int(input())
A = list(map(int, input().split()))
k = 10000
C = [0 for i in range(k)]
B = [0 for i in range(n)]
def CountingSort(A,B,k):
for i in range(n):
C[A[i]] += 1
for i in range(k):
C[i] += C[i-1]
for i in range(n):
B[C[A[i]]-1] = A[i]
C[A[i]] -= 1
CountingSort(A,B,k)
B = " ".join([str(num) for num in B])
print(B)
| Traceback (most recent call last):
File "/tmp/tmp3p5q_xws/tmpgourcl93.py", line 3, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s230090955 | p02275 | u007270338 | 1528170012 | Python | Python3 | py | Runtime Error | 30 | 6724 | 403 | #coding:utf-8
n = int(input())
A = list(map(int, input().split()))
k = 10000
C = [0 for i in range(k)]
B = [0 for i in range(n)]
def CountingSort(A,B,k):
for i in range(n):
C[A[i]] += 1
for i in range(k):
C[i] += C[i-1]
for i in range(n-1,-1,-1):
B[C[A[i]]-1] = A[i]
C[A[i]] -= 1
CountingSort(A,B,k)
B = " ".join([str(num) for num in B])
print(B)
| Traceback (most recent call last):
File "/tmp/tmpczvcrcgi/tmpt0wfrzj2.py", line 3, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s704416795 | p02275 | u007270338 | 1528170054 | Python | Python3 | py | Runtime Error | 20 | 6724 | 395 | #coding:utf-8
n = int(input())
A = list(map(int, input().split()))
k = 10000
C = [0 for i in range(k)]
B = [0 for i in range(n)]
def CountingSort(A,B,k):
for i in range(n):
C[A[i]] += 1
for i in range(k):
C[i] += C[i-1]
for i in range(n):
B[C[A[i]]-1] = A[i]
C[A[i]] -= 1
CountingSort(A,B,k)
B = " ".join([str(num) for num in B])
print(B)
| Traceback (most recent call last):
File "/tmp/tmpgvt3m75m/tmp9odgw5eb.py", line 3, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s050047795 | p02276 | u356729014 | 1551415826 | Python | Python3 | py | Runtime Error | 0 | 0 | 373 | def partition(A, p, r):
x = A[r]
i = p - 1
for j in range(p, r):
if A[j] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
n = int(input())
A = [int(num) for num in input().split()]
p = 0
r = n
q = partition(A, p, r)
A_str = [str(a) for a in A]
A_str[q] = "[" + A_str[q] + "]"
print(" ".join(A_str))
| Traceback (most recent call last):
File "/tmp/tmp8pp7ah7r/tmpas46y63d.py", line 14, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s176338949 | p02276 | u356729014 | 1551416182 | Python | Python3 | py | Runtime Error | 0 | 0 | 367 | def partition(A, p, r):
x = A[r]
i = p - 1
for j in range(p, r):
if A[j] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
n = int(input())
A = [int(num) for num in input().split()]
p = 0
r = n
q = partition(A, p, r)
A_str = [str(a) for a in A]
A_str[q] = "[" + A_str[q] + "]"
print(" ".join(A_str))
| Traceback (most recent call last):
File "/tmp/tmpbqhgp0av/tmphfw_8l77.py", line 13, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s015066530 | p02276 | u356729014 | 1551416362 | Python | Python3 | py | Runtime Error | 0 | 0 | 361 | def partition(A, p, r):
x = A[r]
i = p - 1
for j in range(p, r):
if A[j] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
A = [int(num) for num in input().split()][1:]
p = 0
r = len(A)-1
q = partition(A, p, r)
A_str = [str(a) for a in A]
A_str[q] = "[" + A_str[q] + "]"
print(" ".join(A_str))
| Traceback (most recent call last):
File "/tmp/tmpxesggdkv/tmp2bz0ukfk.py", line 13, in <module>
A = [int(num) for num in input().split()][1:]
^^^^^^^
EOFError: EOF when reading a line
| |
s941511366 | p02276 | u387603681 | 1556265547 | Python | Python3 | py | Runtime Error | 0 | 0 | 306 | def partition(A, p, r):
x = A[r]
i = p-1
for j in range(p, r-1):
if A[j] <= i:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
n = int(input())
*A, = map(int, input().split())
r = A[-1]
p = min(A)
A[partition(A, p, r)] = "["+r+"]"
print(' '.join(A))
| Traceback (most recent call last):
File "/tmp/tmpn8j8t35z/tmpxlaw98a5.py", line 11, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s736819025 | p02276 | u253463900 | 1442386041 | Python | Python3 | py | Runtime Error | 0 | 0 | 467 | def Partition(A,p,r):
x = A[r]
i = p-1
for j in range(p,r):
if (A[j] <= x):
i += 1
A[i],A[j] = A[j],A[i]
A[i+1],A[r] = A[r],A[i+1]
return i+1
n = int(input())
st = input()
data = list(map(int,st.split()))
mid = Partition(data,0,len(data)-1)
for i in range(0,mid):
print(data[i],end=" ")
print("[{0}] ".format(data[mid])))
for i in range(mid+1,len(data)-2):
print(data[i],end=" ")
print(data[len(data)-1]) | File "/tmp/tmplrzkxrfp/tmplq8qdo2i.py", line 19
print("[{0}] ".format(data[mid])))
^
SyntaxError: unmatched ')'
| |
s951000642 | p02276 | u488601719 | 1448793521 | Python | Python3 | py | Runtime Error | 0 | 0 | 290 | def partition(a, p, r):
x = a[r]
i = p - 1
for j in range(p, r):
if a[j] <= x:
i = i + 1
a[i], a[j] = a[j], a[i]
a[i+1], a[r] = a[r], a[i+1]
print(*a)
return i+1
n = int(input())
a = list(map(int, input().split()))
partition(a, 0, n) | Traceback (most recent call last):
File "/tmp/tmpaciffugw/tmp61e35_2c.py", line 12, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s936228354 | p02276 | u488601719 | 1448793695 | Python | Python3 | py | Runtime Error | 0 | 0 | 322 | def partition(a, p, r):
x = a[r]
i = p - 1
for j in range(p, r):
if a[j] <= x:
i = i + 1
a[i], a[j] = a[j], a[i]
a[i+1], a[r] = a[r], a[i+1]
return i+1
n = int(input())
a = list(map(int, input().split()))
m = partition(a, 0, n-1)
a[m] = "[%s]"%(a[m])
print(" ".join(a)) | Traceback (most recent call last):
File "/tmp/tmpzhznh6ui/tmp3s0ga3vz.py", line 11, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s583212725 | p02276 | u963402991 | 1459737470 | Python | Python3 | py | Runtime Error | 0 | 0 | 335 |
def partition(A, p, r):
x = A[r]
i = p - 1
for j in range(p, r):
if A[j] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
n = int(input())
A = list(map(int, input().split()))
q =partition(A, 1, len(A) - 1)
print(*A[:q] + " [{0}] " + *A[q + 1:]) | File "/tmp/tmpro_nfhfu/tmpj34xu_fz.py", line 19
print(*A[:q] + " [{0}] " + *A[q + 1:])
^
SyntaxError: invalid syntax
| |
s392850139 | p02276 | u963402991 | 1459904099 | Python | Python3 | py | Runtime Error | 0 | 0 | 335 |
def partition(A, p, r):
x = A[r]
i = p - 1
for j in range(p, r):
if A[j] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
n = int(input())
A = list(map(int, input().split()))
q =partition(A, 1, len(A) - 1)
print(*A[:q] + " [{0}] " + *A[q + 1:]) | File "/tmp/tmpqnvll4nq/tmp9vorae9w.py", line 19
print(*A[:q] + " [{0}] " + *A[q + 1:])
^
SyntaxError: invalid syntax
| |
s825753577 | p02276 | u918457647 | 1469261346 | Python | Python3 | py | Runtime Error | 0 | 0 | 386 | def partition(a, p, r):
x = a[r]
i = p-1
for j in range(p, r):
if a[j] <= x:
i += 1
tmp = a[i]
a[i] = a[j]
a[j] = tmp
tmp = a[i+1]
a[i+1] = a[r]
a[r] = tmp
return a, i+1
n = int(input())
A = list(map(int, input().split()))
ans, idx = partition(A, 0, n-1)
print(*ans[:idx], [ans[idx]], *ans[idx+1:]) | Traceback (most recent call last):
File "/tmp/tmpspmqxoe1/tmphy56dkpr.py", line 18, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s656947416 | p02276 | u918457647 | 1469261421 | Python | Python3 | py | Runtime Error | 0 | 0 | 386 | def partition(a, p, r):
x = a[r]
i = p-1
for j in range(p, r):
if a[j] <= x:
i += 1
tmp = a[i]
a[i] = a[j]
a[j] = tmp
tmp = a[i+1]
a[i+1] = a[r]
a[r] = tmp
return a, i+1
n = int(input())
A = list(map(int, input().split()))
ans, idx = partition(A, 0, n-1)
print(*ans[:idx], [ans[idx]], *ans[idx+1:]) | Traceback (most recent call last):
File "/tmp/tmphwlm6oo6/tmpy8nlhnr0.py", line 18, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s934012144 | p02276 | u918457647 | 1469261775 | Python | Python3 | py | Runtime Error | 0 | 0 | 314 | def partition(p, r):
x = a[r]
i = p-1
for j in range(p, r):
if a[j] <= x:
i += 1
a[i], a[j] = a[j], a[i]
a[i+1], a[r] = a[r], a[i+1]
return i+1
n = int(input())
a = list(map(int, input().split()))
idx = partition(0, n-1)
print(*a[:idx], [a[idx]], *a[idx+1:]) | Traceback (most recent call last):
File "/tmp/tmpzs1museh/tmpdtky3tgm.py", line 14, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s823548226 | p02276 | u811733736 | 1480892419 | Python | Python3 | py | Runtime Error | 0 | 0 | 920 | def partition(A, p, r):
"""
???????????????????????????????????????A[r]?????°?????????????????????????????????????????????A[r-1]??¨?´??????????????????§??¨???
"""
x = A[r]p
i = p - 1
for j in range(p, r):
if A[j] <= x:
i += 1
temp = A[i]
A[i] = A[j]
A[j] = temp
temp = A[i+1]
A[i+1] = A[r]
A[r] = temp
return i+1
if __name__ == '__main__':
# ??????????????\???
# A = [13, 19, 9, 5, 12, 8, 7, 4, 21, 2, 6, 11]
num_of_data = int(input())
A = [int(x) for x in input().split(' ')]
# ???????????????
p = partition(A, 0, len(A)-1) # ????????????????????????????????????len(A)??§?????????-1???????????????????????????
# ???????????¨???
left = A[:p]
partition = A[p]
right = A[p+1:]
print('{0} [{1}] {2}'.format(' '.join(map(str, left)), partition, ' '.join(map(str, right)))) | File "/tmp/tmpe0l5wtok/tmp1wew1hjy.py", line 5
x = A[r]p
^
SyntaxError: invalid syntax
| |
s365250637 | p02276 | u564398841 | 1486264075 | Python | Python3 | py | Runtime Error | 0 | 0 | 546 | def partition(A, p, r):
x = A[r]
i = p - 1
for j in range(p, r):
if A[j] < x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
fin = open('sample.txt')
input = fin.readline
if __name__ == '__main__':
N = int(input().strip())
AA = [int(a) for a in input().strip().split()]
i = partition(AA, 0, N - 1)
_str = ' '.join([str(a) for a in AA[:i]]) + \
' [{}] '.format(AA[i]) + \
' '.join([str(a) for a in AA[i+1:]])
print(_str) | Traceback (most recent call last):
File "/tmp/tmpnu2ot5e7/tmpn14n4f1e.py", line 12, in <module>
fin = open('sample.txt')
^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'sample.txt'
| |
s330649724 | p02276 | u300946041 | 1490582153 | Python | Python3 | py | Runtime Error | 0 | 0 | 413 | # -*- coding: utf-8 -*-
def partition(A, p, r):
x = A[r]
i = p
for j in range(1, r):
if A[j] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i], A[r] = A[r], A[i]
return i
def main():
n = int(input())
A = [int(e) for e in input().split()]
p = 0
r = len(A) - 1
idx = partition(A, p, r)
A[idx] = "[%s]" % A[idx]
return " ".join(A)
main() | Traceback (most recent call last):
File "/tmp/tmppwglp9sl/tmp2l1g29ft.py", line 24, in <module>
main()
File "/tmp/tmppwglp9sl/tmp2l1g29ft.py", line 16, in main
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s394720646 | p02276 | u546285759 | 1492338485 | Python | Python3 | py | Runtime Error | 0 | 0 | 310 | def partition(A, p, r):
x = A[r]
i = p-1
for j in range(p, r):
if A[j] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i+1], A[r] = A[r], A[i+1]
return i+1
n = int(input())
A = list(map(int, input().split()))
i = partition(A, 0, n)
A[i] = "["+str(A[i])+"]"
print(*A) | Traceback (most recent call last):
File "/tmp/tmp4qo0i9ig/tmprvmqmdz5.py", line 11, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s888926531 | p02276 | u426534722 | 1498489422 | Python | Python3 | py | Runtime Error | 0 | 0 | 397 | def partition(p, r):
x = A[r]
i = p - 1
for j in range(p, r):
if A[j] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
n = int(input())
A = [int(i) for i in input().split()]
q = partition(0, n - 1);
print(*A[:q], "[" + str(A[q]) + "]", end="")
if len(A[q + 1:]) > 0:
print("", *A[q + 1:])
else:
print("") | Traceback (most recent call last):
File "/tmp/tmp0dhzixe2/tmp8fvj6bay.py", line 10, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s728948316 | p02276 | u426534722 | 1498489502 | Python | Python3 | py | Runtime Error | 0 | 0 | 377 | def partition(p, r):
x = A[r]
i = p - 1
for j in range(p, r):
if A[j] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
n = int(input())
A = [int(i) for i in input().split()]
q = partition(0, n - 1);
print(*A[:q], "[" + str(A[q]) + "]", end="")
if len(A[q + 1:]) > 0:
print("", *A[q + 1:]) | Traceback (most recent call last):
File "/tmp/tmprppu92js/tmpv2k2kjdc.py", line 10, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s538195242 | p02276 | u426534722 | 1498489539 | Python | Python3 | py | Runtime Error | 0 | 0 | 378 | n = int(input())
A = [int(i) for i in input().split()]
def partition(p, r):
x = A[r]
i = p - 1
for j in range(p, r):
if A[j] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
q = partition(0, n - 1);
print(*A[:q], "[" + str(A[q]) + "]", end="")
if len(A[q + 1:]) > 0:
print("", *A[q + 1:]) | Traceback (most recent call last):
File "/tmp/tmpucfahxxj/tmpsjun97oj.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s014981213 | p02276 | u426534722 | 1498489752 | Python | Python3 | py | Runtime Error | 0 | 0 | 377 | n = int(input())
A = [int(i) for i in input().split()]
def partition(p, r):
x = A[r]
i = p - 1
for j in range(p, r):
if A[j] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
q = partition(0, n - 1)
print(*A[:q], "[" + str(A[q]) + "]", end="")
if len(A[q + 1:]) > 0:
print("", *A[q + 1:]) | Traceback (most recent call last):
File "/tmp/tmpt5sp3c8_/tmp57kndo5q.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s773487402 | p02276 | u193453446 | 1501834803 | Python | Python3 | py | Runtime Error | 0 | 0 | 1409 | import sys
def swap(A, i, j):
x = A[i]
A[i] = A[j]
A[j] = x
def partition(A, p, r, idx):
x = A[r][idx] # 1 x = A[r]
i = p - 1 # 2 i = p-1
for j in range(p, r): # 3 for j = p to r-1
if A[j][idx] <= x: # 4 if A[j] <= x
i += 1 # 5 then i = i+1
if(i != j):
swap(A, i, j) # 6 exchange A[i] and A[j]
i += 1
swap(A, i, r) # 7 exchange A[i+1] and A[r]
return i # 8 return i+1
def quickSort(A, p, r, idx):
if p < r:
q = partition(A, p, r, idx)
quickSort(A, p, q - 1, idx)
quickSort(A, q + 1, r, idx)
def main():
""" ????????? """
num = int(input().strip())
istr = sys.stdin.read()
cards = list(istr.splitlines())
A = [[0,0] for i in range(num)]
B = [[0,0] for i in range(num)]
for i in range(num):
A[i][0] = cards[i][0]
A[i][1] = int(cards[i][2:])
B[i][0] = cards[i][0]
B[i][1] = int(cards[i][2:])
quickSort(A, 0, num-1,1)
B.sort(key = lambda d:d[1])
res = "Stable"
for i in range(num):
if A[i][0] != B[i][0] or A[i][1] != B[i][1]:
res = "Not stable"
break
print(res)
for x in A:
print(" ".join(map(str, x)))
if __name__ == '__main__':
main() | Traceback (most recent call last):
File "/tmp/tmpkyp506k0/tmpe4qedthy.py", line 54, in <module>
main()
File "/tmp/tmpkyp506k0/tmpe4qedthy.py", line 28, in main
num = int(input().strip())
^^^^^^^
EOFError: EOF when reading a line
| |
s574054424 | p02276 | u918276501 | 1507977754 | Python | Python3 | py | Runtime Error | 0 | 0 | 305 | def partition(A,p=0, r=None):
if r is None:
r = len(A)-1
x = A[r]
i = p-1
for j in range(p,r):
while A[j] <= x:
i += 1
swap(A,i,j)
swap(A,i+1,r)
return i+1
k = partition(A)
B = list(map(str, A))
B[k] = "[{}]".format(B[k])
print(" ".join(B)) | Traceback (most recent call last):
File "/tmp/tmpkaown_6u/tmpk60__cq_.py", line 13, in <module>
k = partition(A)
^
NameError: name 'A' is not defined
| |
s209213016 | p02276 | u918276501 | 1507977830 | Python | Python3 | py | Runtime Error | 0 | 0 | 407 | def partition(A,p=0, r=None):
if r is None:
r = len(A)-1
x = A[r]
i = p-1
for j in range(p,r):
while A[j] <= x:
i += 1
swap(A,i,j)
swap(A,i+1,r)
return i+1
if __name__ == "__main__:
input()
A = list(map(int, input().strip().split()))
k = partition(A)
B = list(map(str, A))
B[k] = "[{}]".format(B[k])
print(" ".join(B)) | File "/tmp/tmpy4dvjxag/tmp6sdh0eki.py", line 13
if __name__ == "__main__:
^
SyntaxError: unterminated string literal (detected at line 13)
| |
s992520929 | p02276 | u918276501 | 1507977918 | Python | Python3 | py | Runtime Error | 20 | 7732 | 465 | def swap(A,i,j):
A[i],A[j] = A[j],A[i]
return A
def partition(A,p=0, r=None):
if r is None:
r = len(A)-1
x = A[r]
i = p-1
for j in range(p,r):
while A[j] <= x:
i += 1
swap(A,i,j)
swap(A,i+1,r)
return i+1
if __name__ == "__main__":
input()
A = list(map(int, input().strip().split()))
k = partition(A)
B = list(map(str, A))
B[k] = "[{}]".format(B[k])
print(" ".join(B)) | Traceback (most recent call last):
File "/tmp/tmpjs1lkl4h/tmptvg1rv8r.py", line 18, in <module>
input()
EOFError: EOF when reading a line
| |
s760473715 | p02276 | u918276501 | 1507978050 | Python | Python3 | py | Runtime Error | 20 | 7664 | 465 | def swap(A,i,j):
A[i],A[j] = A[j],A[i]
return A
def partition(A,p=0, r=None):
if r is None:
r = len(A)-1
x = A[r]
i = p-1
for j in range(p,r):
while A[j] <= x:
i += 1
swap(A,i,j)
swap(A,i+1,r)
return i+1
if __name__ == "__main__":
input()
A = list(map(int, input().strip().split()))
k = partition(A)
B = list(map(str, A))
B[k] = "[{}]".format(B[k])
print(" ".join(B)) | Traceback (most recent call last):
File "/tmp/tmp95_4x1rq/tmpyzksu_0_.py", line 18, in <module>
input()
EOFError: EOF when reading a line
| |
s293091259 | p02276 | u024715419 | 1508301757 | Python | Python3 | py | Runtime Error | 0 | 0 | 222 | n = int(input())
a = list(map(int,input().split()))
x = a[-1]
i = -1
for j in range(len(a)-1):
if a[j] <= x:
i += 1
a[i], a[j] = a[j], a[i]
a[i + 1], a[n] = "[" + str(a[n]) + "]", a[i + 1]
print(*a) | Traceback (most recent call last):
File "/tmp/tmpbkxnx0__/tmp8fxczigx.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s234753546 | p02276 | u150984829 | 1518707515 | Python | Python3 | py | Runtime Error | 0 | 0 | 213 | n=int(input())-1
A=list(map(int,input().split()))
i=0
for j in range(n):
if A[j]<=A[-1]:A[i],A[j]=A[j],A[i];i+=1
A[i],A[n]=A[n],A[i]
print(" ".join(map(str,A[:k]))+" ["+str(A[i])+"] "+" ".join(map(str,A[k+1:])))
| Traceback (most recent call last):
File "/tmp/tmpsxl7cy7z/tmps916glmn.py", line 1, in <module>
n=int(input())-1
^^^^^^^
EOFError: EOF when reading a line
| |
s472070148 | p02276 | u150984829 | 1520050949 | Python | Python3 | py | Runtime Error | 0 | 0 | 253 | def s():
n=int(input())-1
A=list(map(int,input().split()))
i=0
for j in range(n):A[j]<=A[-1]and A[i],A[j]=A[j],A[i];i+=1
A[i],A[n]=A[n],A[i]
print(" ".join(map(str,A[:i]))+" ["+str(A[i])+"] "+" ".join(map(str,A[i+1:])))
if'__main__'==__name__:s()
| File "/tmp/tmp8oz7buo_/tmpznw82p7o.py", line 5
for j in range(n):A[j]<=A[-1]and A[i],A[j]=A[j],A[i];i+=1
^^^^
SyntaxError: cannot assign to subscript here. Maybe you meant '==' instead of '='?
| |
s937400055 | p02276 | u559106458 | 1529402274 | Python | Python3 | py | Runtime Error | 0 | 0 | 469 | MAX=100000
list=[]
def partition(p,r):
t=0
x=list[r]
i=p-1
j=p
while(j<r):
if(int(list[j])<=x):
i+=1
t=int(list[i])
list[i]=list[j]
list[j]=t
j+=1
t=int(list[i+1])
list[i+1]=list[r]
list[r]=t
return i+1
n=int(input())
i=0
while(i<n):
list.append(int(input()))
i+=1
q=partition(0,n-1)
i=0
while(i<n):
if(i==q):
print("[",end="")
print(str(list[i]),end="")
print("]",end="")
else:
print(str(list[i])+" ",end="")
i+=1
print()
| Traceback (most recent call last):
File "/tmp/tmpoasgxhj0/tmpp2sjeoko.py", line 23, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s268990490 | p02276 | u559106458 | 1529402634 | Python | Python3 | py | Runtime Error | 0 | 0 | 531 | list=[]
def partition(p,r):
t=0
x=list[r]
i=p-1
j=p
while(j<r):
if(int(list[j])<=x):
i+=1
t=int(list[i])
list[i]=list[j]
list[j]=t
j+=1
t=int(list[i+1])
list[i+1]=list[r]
list[r]=t
return i+1
def main():
n=int(input())
i=0
while(i<n):
list.append(int(input()))
i+=1
q=partition(0,n-1)
i=0
while(i<n):
if(i==q):
print("[",end="")
print(str(list[i]),end="")
print("] ",end="")
else:
print(str(list[i])+" ",end="")
i+=1
print()
return 0
if __name__ == "__main__":
main()
| Traceback (most recent call last):
File "/tmp/tmpm86w738o/tmpg_dpfqy9.py", line 43, in <module>
main()
File "/tmp/tmpm86w738o/tmpg_dpfqy9.py", line 23, in main
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s017832533 | p02276 | u559106458 | 1529402914 | Python | Python3 | py | Runtime Error | 0 | 0 | 531 | list=[]
def partition(p,r):
t=0
x=list[r]
i=p-1
j=p
while(j<r):
if(int(list[j])<=x):
i+=1
t=int(list[i])
list[i]=list[j]
list[j]=t
j+=1
t=int(list[i+1])
list[i+1]=list[r]
list[r]=t
return i+1
def main():
n=int(input())
i=0
while(i<n):
list.append(int(input()))
i+=1
q=partition(0,n-1)
i=0
while(i<n):
if(i==q):
print("[",end="")
print(str(list[i]),end="")
print("] ",end="")
else:
print(str(list[i])+" ",end="")
i+=1
print()
return 0
if __name__ == "__main__":
main()
| Traceback (most recent call last):
File "/tmp/tmpma2m3l2c/tmplamippxt.py", line 43, in <module>
main()
File "/tmp/tmpma2m3l2c/tmplamippxt.py", line 23, in main
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s259190785 | p02276 | u559106458 | 1529403676 | Python | Python3 | py | Runtime Error | 0 | 0 | 539 | list=[]
def partition(p,r):
t=0
x=list[r]
i=p-1
j=p
while(j<r):
if(int(list[j])<=x):
i+=1
t=int(list[i])
list[i]=list[j]
list[j]=t
j+=1
t=int(list[i+1])
list[i+1]=list[r]
list[r]=t
return i+1
def main():
n=int(input())
i=0
while(i<n):
list.append(int(input().split()))
i+=1
q=partition(0,n-1)
i=0
while(i<n):
if(i==q):
print("[",end="")
print(str(list[i]),end="")
print("] ",end="")
else:
print(str(list[i])+" ",end="")
i+=1
print()
return 0
if __name__ == "__main__":
main()
| Traceback (most recent call last):
File "/tmp/tmpghlvuwcz/tmp4uy5fo3f.py", line 43, in <module>
main()
File "/tmp/tmpghlvuwcz/tmp4uy5fo3f.py", line 23, in main
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s828433104 | p02277 | u153665391 | 1532150242 | Python | Python3 | py | Runtime Error | 40 | 6344 | 1486 | import copy
def partition(p, r):
i = p
for j in range(p, r):
if A[r][1] >= A[j][1]:
A[i], A[j] = A[j], A[i]
i += 1
A[r], A[i] = A[i], A[r]
return i
def quick_sort(p, r):
if p < r:
q = partition(p, r)
quick_sort(p, q-1)
quick_sort(q+1, r)
def correct_same_num_suits(l, num, first, ele_cnt):
suits = []
for i in range(first, N):
if num == l[i][1]:
suits.append(l[i][0])
if ele_cnt == len(suits):
break
return suits
def is_stable():
idx = 0
while idx < N-1:
idx_incr_flg = True
if A[idx][1] == A[idx+1][1]:
num = A[idx][1]
j = idx
ele_cnt = 0
while num == A[j][1]:
ele_cnt += 1
j += 1
sorted_suits = correct_same_num_suits(A, num, idx, ele_cnt)
orig_suits = correct_same_num_suits(orig_list, num, 0, ele_cnt)
if sorted_suits != orig_suits:
return False
idx += len(sorted_suits)
idx_incr_flg = False
if idx_incr_flg:
idx += 1
return True
N = int(input())
A = []
for _ in range(N):
suit, num = input().split()
num = int(num)
A.append([suit, num])
orig_list = copy.deepcopy(A)
quick_sort(0, N-1)
is_stable = is_stable()
if is_stable:
print("Stable")
else:
print("Not stable")
for card in A:
print("%s %d" % (card[0], card[1]))
| Traceback (most recent call last):
File "/tmp/tmpd28sf0qf/tmpoox1d04j.py", line 49, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s351724737 | p02277 | u363774867 | 1556201932 | Python | Python3 | py | Runtime Error | 0 | 0 | 1242 | import copy
INF = 10000000000
def merge(A, left, mid, right):
count = 0
L = A[left:mid] + [(INF,INF)]
R = A[mid:right] + [(INF,INF)]
i, j = 0, 0
for k in range(left, right):
count = count + 1
if L[i][1] <= R[j][1]:
A[k] = L[i]
i = i + 1
else:
A[k] = R[j]
j = j + 1
return count
def mergeSort(A, left, right):
if left + 1 < right:
mid = (left + right) // 2
countL = mergeSort(A, left, mid)
countR = mergeSort(A, mid, right)
return merge(A, left, mid, right) + countL + countR
return 0
def partition(a,p,r):
x=a[r]
i=p-1
for j in range(p,r):
if a[j]<=x:
i+=1
a[i],a[j]=a[j],a[i]
a[i+1],a[r]=a[r],a[i+1]
return i+1
def quickSort(a,p,r):
if p<r:
q=partition(a,p,r)
quicksort(a,p,q-1)
quicksort(a,q+1,r)
n = int(input())
A = [None for i in range(n)]
for i in range(n):
a, b = input().split()
A[i] = (a, int(b))
B = copy.deepcopy(A)
quickSort(A, 0, n-1)
mergeSort(B, 0, n)
if A == B:
print("Stable")
else:
print("Not stable")
ans = [str(x[0]) +" "+str(x[1]) for x in A]
ans = '\n'.join(ans)
print(ans)
| Traceback (most recent call last):
File "/tmp/tmpa3sh9s3i/tmp1dv0oq3b.py", line 41, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s609627580 | p02277 | u363774867 | 1556202310 | Python | Python3 | py | Runtime Error | 0 | 0 | 1247 | import copy
INF = 10000000000
def merge(A, left, mid, right):
count = 0
L = A[left:mid] + [(INF,INF)]
R = A[mid:right] + [(INF,INF)]
i, j = 0, 0
for k in range(left, right):
count = count + 1
if L[i][1] <= R[j][1]:
A[k] = L[i]
i = i + 1
else:
A[k] = R[j]
j = j + 1
return count
def mergeSort(A, left, right):
if left + 1 < right:
mid = (left + right) // 2
countL = mergeSort(A, left, mid)
countR = mergeSort(A, mid, right)
return merge(A, left, mid, right) + countL + countR
return 0
def partition(a,p,r):
x=a[r][1]
i=p-1
for j in range(p,r):
if a[j][1]<=x:
i+=1
a[i],a[j]=a[j],a[i]
a[i+1],a[r]=a[r],a[i+1]
return i+1
def quickSort(a,p,r):
if p<r:
q=partition(a,p,r)
quicksort(a,p,q-1)
quicksort(a,q+1,r)
n = int(input())
A = [None for i in range(n)]
for i in range(n):
a, b = input().split()
A[i] = (a, int(b))
B = copy.deepcopy(A)
quickSort(A, 0, n-1)
mergeSort(B, 0, n)
if A == B:
print("Stable")
else:
print("Not stable")
ans = [str(x[0]) +" "+str(x[1]) for x in A]
ans = '\n'.join(ans)
print(ans)
| Traceback (most recent call last):
File "/tmp/tmprbjbk_mm/tmpg6yefc6h.py", line 41, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s981716302 | p02277 | u363774867 | 1556202363 | Python | Python3 | py | Runtime Error | 0 | 0 | 1245 | import copy
INF = 10000000000
def merge(A, left, mid, right):
count = 0
L = A[left:mid] + [(INF,INF)]
R = A[mid:right] + [(INF,INF)]
i, j = 0, 0
for k in range(left, right):
count = count + 1
if L[i][1] <= R[j][1]:
A[k] = L[i]
i = i + 1
else:
A[k] = R[j]
j = j + 1
return count
def mergeSort(A, left, right):
if left + 1 < right:
mid = (left + right) // 2
countL = mergeSort(A, left, mid)
countR = mergeSort(A, mid, right)
return merge(A, left, mid, right) + countL + countR
return 0
def partition(a,p,r):
x=a[r][1]
i=p-1
for j in range(p,r):
if a[j][1]<=x:
i+=1
a[i],a[j]=a[j],a[i]
a[i+1],a[r]=a[r],a[i+1]
return i+1
def quickSort(a,p,r):
if p<r:
q=partition(a,p,r)
quicksort(a,p,q-1)
quicksort(a,q+1,r)
n = int(input())
A = [None for i in range(n)]
for i in range(n):
a, b = input().split()
A[i] = (a, int(b))
B = copy.deepcopy(A)
quickSort(A, 0, n-1)
mergeSort(B, 0, n)
if A == B:
print("Stable")
else:
print("Not stable")
ans = [str(x[0]) +" "+str(x[1]) for x in A]
ans = '\n'.join(ans)
print(ans)
| Traceback (most recent call last):
File "/tmp/tmplfpt6fts/tmpyvc1tlfw.py", line 41, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s574950056 | p02277 | u805716376 | 1556771183 | Python | Python3 | py | Runtime Error | 0 | 0 | 777 | a = []
n = int(input())
for _ in range(n):
s, i = input().split()
a += [(s, int(i))]
b.setdefault(int(d), []).append(v)
b = {val: iter(s).__next__ for val, s in D.items()}
def partition(a, left, right):
standard = a[right][1]
cnt = left
for i in range(left, right):
if a[i][1] <= standard:
a[cnt],a[i] = a[i], a[cnt]
cnt += 1
a[cnt],a[i] = a[i], a[cnt]
return cnt
def quickSort(a, left = 0, right = len(a) - 1):
if 1 <= right - left:
cnt_ = partition(a, left, right)
quickSort(a,left, cnt_ - 1)
quickSort(a,cnt_ + 1, right)
quickSort(a, 0 , len(a)-1)
ok = 1
for v, d in A:
if D[d]() != v:
ok = 0
print(['Not stable','Stable'][ok])
for i in range(n):
print(*a[i])
| Traceback (most recent call last):
File "/tmp/tmp20bdaha8/tmpgybgs0ow.py", line 2, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s086753553 | p02277 | u805716376 | 1556771233 | Python | Python3 | py | Runtime Error | 0 | 0 | 784 | a = []
b = {}
n = int(input())
for _ in range(n):
s, i = input().split()
a += [(s, int(i))]
b.setdefault(int(d), []).append(v)
b = {val: iter(s).__next__ for val, s in D.items()}
def partition(a, left, right):
standard = a[right][1]
cnt = left
for i in range(left, right):
if a[i][1] <= standard:
a[cnt],a[i] = a[i], a[cnt]
cnt += 1
a[cnt],a[i] = a[i], a[cnt]
return cnt
def quickSort(a, left = 0, right = len(a) - 1):
if 1 <= right - left:
cnt_ = partition(a, left, right)
quickSort(a,left, cnt_ - 1)
quickSort(a,cnt_ + 1, right)
quickSort(a, 0 , len(a)-1)
ok = 1
for v, d in A:
if D[d]() != v:
ok = 0
print(['Not stable','Stable'][ok])
for i in range(n):
print(*a[i])
| Traceback (most recent call last):
File "/tmp/tmpf79ogt1r/tmpxxdzwl7a.py", line 3, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s403333794 | p02277 | u805716376 | 1556771279 | Python | Python3 | py | Runtime Error | 0 | 0 | 784 | a = []
b = {}
n = int(input())
for _ in range(n):
s, i = input().split()
a += [(s, int(i))]
b.setdefault(int(i), []).append(s)
b = {val: iter(s).__next__ for val, s in D.items()}
def partition(a, left, right):
standard = a[right][1]
cnt = left
for i in range(left, right):
if a[i][1] <= standard:
a[cnt],a[i] = a[i], a[cnt]
cnt += 1
a[cnt],a[i] = a[i], a[cnt]
return cnt
def quickSort(a, left = 0, right = len(a) - 1):
if 1 <= right - left:
cnt_ = partition(a, left, right)
quickSort(a,left, cnt_ - 1)
quickSort(a,cnt_ + 1, right)
quickSort(a, 0 , len(a)-1)
ok = 1
for v, d in A:
if D[d]() != v:
ok = 0
print(['Not stable','Stable'][ok])
for i in range(n):
print(*a[i])
| Traceback (most recent call last):
File "/tmp/tmpijc5gju3/tmp_e1wbrvj.py", line 3, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s067568932 | p02277 | u567380442 | 1421672814 | Python | Python3 | py | Runtime Error | 0 | 0 | 737 | def partition(a, p, r):
q = p
for i in range(p, r):
if a[i][1] <= a[r][1]:
a[q], a[i] = a[i], a[q]
q += 1
a[q], a[r] = a[r], a[q]
return q
def quicksort(a, p, r):
if p < r:
q = partition(a, p, r)
quicksort(a, p, q-1)
quicksort(a, q+1, r)
def check_stable(a):
for i in range(1, len(a)):
if a[i - 1][1] == a[i][1]:
if a[i - 1][2] > a[i][2]:
return 'Not stable'
return 'Stable '
import sys
n = sys.stdin.readline()
a = []
for i in range(n):
suit, num = sys.stdin.readline().split()
a += [[suit, int(num), i]]
quicksort(a, 0, len(a) - 1)
print(check_stable(a))
for line in a:
print(line[0],line[1]) | Traceback (most recent call last):
File "/tmp/tmp5u48rlam/tmps2whu9oz.py", line 26, in <module>
for i in range(n):
^^^^^^^^
TypeError: 'str' object cannot be interpreted as an integer
| |
s359738590 | p02277 | u885889402 | 1442389202 | Python | Python3 | py | Runtime Error | 0 | 0 | 832 | def partition(a,p,r):
x=int(a[r][1:])
i=p-1
for j in range(p,r):
if(int(a[j][1:])<=x):
i+=1
a[i],a[j]=a[j],a[i]
a[i+1],a[r]=a[r],a[i+1]
return i+1
def quicksort(a,p,r):
if(p<r):
q=partition(a,p,r)
quicksort(a,p,q-1)
quicksort(a,q+1,r)
a=[]
n=int(input())
for i in range(n):
s=input()
a.append("".join(s.split()))
b=list(a)
strr_bubble_sort(b,n)
c=list(a)
quicksort(c,0,n-1)
d=dict()
i=0
x="-1"
for i in c:
if(x!=i[1:]):
d[i[1:]]=[i[:1]]
x=i[1:]
else:
d[x].append(i[:1])
print(d)
message="Stable"
for i in reversed(a):
if(i[1:] in d):
print(d)
if(d[i[1:]].pop()!=i[:1]):
message="Not stable"
break
print(message)
for i in c:
print("%s %s"%(i[:1],i[1:])) | Traceback (most recent call last):
File "/tmp/tmpn5w1j1v3/tmppz40qkkm.py", line 18, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s080917881 | p02277 | u894381890 | 1442389923 | Python | Python | py | Runtime Error | 10 | 6364 | 1446 | import sys
def partition(A, p, r):
x = int(A[r][1])
i = p - 1
for j in range(p, r):
if int(A[j][1]) <= x:
i = i + 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
def quickSort(A, p, r):
if p < r:
q = partition(A, p, r)
quickSort(A, p, q - 1)
quickSort(A, q + 1, r)
def tru(b, c):
if int(b) == int(c):
return True
def sta(tramplist, before_list, p, r):
Af_list = []
Be_list = []
for i in range(n):
a = 0
Af = []
Af.append(tramp_list[i][1])
Af.append(tramp_list[i][0])
while a < 4:
if tru(int(tramplist[i][1]), int(tramplist[i + a][1])) and i + a + i < n:
a += 1
Af.append(tramp_list[i+a+1][0])
else:
Af_list.append(Af)
i += a
a = 0
break
for i in range(len(Af_list)):
Be = []
Be.append(Af_list[i][0])
for j in range(r):
if int(before_list[j][1]) == int(Af_list[i][0]):
Be.append(before_list[j][0])
else:
Be_list.append(Be)
if Af_list != Be_list:
print 'Not stable'
else:
print 'stable'
n = sys.stdin.readline()
n = int(n)
data_list = []
tramp_list = []
befor_list = []
for i in range(n):
text = raw_input()
data_list = text.split(" ")
tramp_list.append(data_list)
before_list = list(tramp_list)
quickSort(tramp_list, 0, n-1)
sta(tramp_list, before_list, 0, n-1)
for i in tramp_list:
print " ".join(i) | File "/tmp/tmpt6z512qz/tmpmm1q2lwu.py", line 52
print 'Not stable'
^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s890525307 | p02277 | u253463900 | 1442476760 | Python | Python3 | py | Runtime Error | 0 | 0 | 1496 | def Partition(A,p,r):
x = A[r]
i = p-1
for j in range(p,r):
if (A[j] <= x):
i += 1
A[i],A[j] = A[j],A[i]
A[i+1],A[r] = A[r],A[i+1]
return i+1
def qsort(A,p,r):
if p < r:
q = Partition(A,p,r)
qsort(A,p,q-1)
qsort(A,q+1,r)
class card(object):
def __init__(self, str):
data = str.split()
self.symbol,self.num = data[0],int(data[1])
def __le__(self,obj):
if(self.num <= obj.num):
return True
else:
return False
def __ge__(self,obj):
if(self.num >= obj.num):
return True
else:
return False
def display_card(self):
print("{0} {1}".format(self.symbol,self.num))
c = []
n = int(input())
while(n>0):
c.append(card(input()))
n -= 1
c_org = c.copy()
qsort(c,0,len(c)-1)
notStable = False
for i in range(1,len(c)):
if(c[i-1].num == c[i].num):
firstCard = c[i-1]
secondCard = c[i]
is_found_1st = False
is_found_2nd = False
for org in c_org:
if(org == firstCard):
is_found_1st = True
if(org == secondCard):
is_found_2nd = True
if(is_found_1st == True):
break
else:
notStable = True
break
if(notstable == 1):
print('Not stable')
else:
print('Stable')
for x in c:
x.display_card() | Traceback (most recent call last):
File "/tmp/tmpj_sp086f/tmpeckmyqy3.py", line 37, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s449351581 | p02277 | u313994256 | 1442583714 | Python | Python | py | Runtime Error | 0 | 0 | 1519 | def mergesort(A, left, right):
if left + 1 < right:
mid = (left + right)/2
mergesort(A, left, mid)
mergesort(A, mid, right)
merge(A, left, mid, right)
def merge(A, left, mid, right):
n1 = mid -left
n2 = right - mid
L = []
R = []
x = [" "," ", 1000000000000000000000000000000000000000000000000]
for i in range(0, n1):
L.append(A[left + i])
for i in range(0, n2):
R.append(A[mid + i])
L.append(x)
R.append(x)
i = 0
j = 0
for k in range(left, right):
if int(L[i][-1]) <= int(R[j][-1]):
A[k] = L[i]
i = i + 1
else:
A[k] = R[j]
j = j + 1
# kannsei
def partition(A, p, r):
x = int(A[r-1][2])
i = p - 1
for j in range(p, r-1):
if int(A[j][2]) <= x:
i = i + 1
A[i],A[j]=A[j], A[i]
A[i+1], A[r-1]=A[r-1], A[i+1]
return i+1
def quicksort(A, p, r):
if p < r-1:
q = partition(A, p, r)
quicksort(A, p, q)
quicksort(A, q+1, r)
if __name__ == "__main__":
num = int(raw_input())
num_list = []
num_list1 = []
for i in range(num):
num_list.append(raw_input())
num_list1 = list(num_list)
quicksort(num_list, 0, len(num_list))
mergesort(num_list1, 0, len(num_list1))
if num_list == num_list1:
print ("Stable")
else:
print ("NOt stable")
print " \n".join(num_list) | File "/tmp/tmpsn_204bb/tmpqfxfgaoq.py", line 77
print " \n".join(num_list)
^
IndentationError: unindent does not match any outer indentation level
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.