s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s755097651
p02277
u313994256
1442583732
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 = [" "," ", 10000...
s960104671
p02277
u313994256
1442584006
Python
Python
py
Runtime Error
0
0
1491
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 = [" "," ", 10000...
s076138227
p02277
u313994256
1442584101
Python
Python
py
Runtime Error
0
0
1490
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 = [" "," ", 10000...
s761710190
p02277
u313994256
1442755215
Python
Python
py
Runtime Error
0
0
1531
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 = [" "," ", 10000...
s239685672
p02277
u313994256
1442755272
Python
Python
py
Runtime Error
0
0
1531
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 = [" "," ", 10000...
s389442742
p02277
u313994256
1442755317
Python
Python
py
Runtime Error
0
0
1532
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 = [" "," ", 10000...
s508357251
p02277
u313994256
1442761751
Python
Python
py
Runtime Error
0
0
1499
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 = [" "," ", ...
s505383031
p02277
u313994256
1442762617
Python
Python
py
Runtime Error
0
0
1506
#????????? 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 =...
s452327356
p02277
u313994256
1442795581
Python
Python
py
Runtime Error
0
0
1498
#????????? 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 =...
s809966355
p02277
u731710433
1455975495
Python
Python3
py
Runtime Error
20
7812
918
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) q...
s717670848
p02277
u742013327
1478604971
Python
Python3
py
Runtime Error
0
0
1421
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_C&lang=jp def partition(target_list, l, r): x = int(target_list[r][1:]) i = l - 1 for j in range(l, r): if int(target_list[j][1:]) <= x: i = i + 1 tmp = target_list[i] target_list[i] = target_list...
s433995968
p02277
u742013327
1478605012
Python
Python3
py
Runtime Error
0
0
1437
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_C&lang=jp def partition(target_list, l, r): x = int(target_list[r][1:]) i = l - 1 for j in range(l, r): if int(target_list[j][1:]) <= x: i = i + 1 tmp = target_list[i] target_list[i] = target_list...
s894782368
p02277
u022407960
1478848723
Python
Python3
py
Runtime Error
0
0
1855
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Input: 6 D 3 H 2 D 1 S 3 D 2 C 1 Output: Not stable / Stable D 1 C 1 D 2 H 2 D 3 S 3 """ import sys import copy def partition(array, start, end): x = int(array[end][2:]) i = start - 1 assert start <= end for j in range(start, end): if int(arr...
s690557776
p02277
u811733736
1480892093
Python
Python3
py
Runtime Error
20
7876
2044
def merge_sort(A, left, right): if left + 1 < right: mid = (left + right) // 2 merge_sort(A, left, mid) merge_sort(A, mid, right) merge(A, left, mid, right) def merge(A, left, mid, right): n1 = mid - left n2 = right - mid L = A[left:mid] R = A[mid:right] L.appen...
s537923096
p02277
u512342660
1484106313
Python
Python
py
Runtime Error
0
0
1747
def partition(A,B,p,r): x = A[r] i = p-1 for j in xrange(p,r): if A[j] <= x: i += 1 tmp = A[i] A[i] = A[j] A[j] = tmp tmp = B[i] B[i] = B[j] B[j] = tmp tmp = A[i+1] A[i+1] = A[r] A[r] = tmp tmp = B[i+...
s604361014
p02277
u564398841
1486271349
Python
Python3
py
Runtime Error
0
0
1269
def mergesort(A, s, e): if s + 1 < e: m = (e + s) // 2 mergesort(A, s, m) mergesort(A, m, e) merge(A, s, m, e) def merge(A, s, m, e): L = A[s:m] + [('*', 1E10)] R = A[m:e] + [('*', 1E10)] ix_l = ix_r = 0 for ix in range(s, e): if L[ix_l][1] < R[ix_r][1]: ...
s360806683
p02277
u564398841
1486271489
Python
Python3
py
Runtime Error
0
0
1273
def mergesort(A, s, e): if s + 1 < e: m = (e + s) // 2 mergesort(A, s, m) mergesort(A, m, e) merge(A, s, m, e) def merge(A, s, m, e): L = A[s:m] + [('*', 1E10)] R = A[m:e] + [('*', 1E10)] ix_l = ix_r = 0 for ix in range(s, e): if L[ix_l][1] < R[ix_r][1]: ...
s369710370
p02277
u918276501
1507982244
Python
Python3
py
Runtime Error
0
0
937
def swap(A,i,j): A[i],A[j] = A[j],A[i] return A def isStable(A): for i in range(1, len(A)): if A[i][1] == A[i-1][1]: if A[i][2] < A[i-1][2]: return False return True def partition(A,p=0, r=None): if r is None: r = len(A)-1 x = A[r] i = p-1 fo...
s906880370
p02277
u918276501
1507982262
Python
Python3
py
Runtime Error
0
0
937
def swap(A,i,j): A[i],A[j] = A[j],A[i] return A def isStable(A): for i in range(1, len(A)): if A[i][1] == A[i-1][1]: if A[i][2] < A[i-1][2]: return False return True def partition(A,p=0, r=None): if r is None: r = len(A)-1 x = A[r] i = p-1 fo...
s184233842
p02277
u918276501
1507982383
Python
Python3
py
Runtime Error
0
0
943
def swap(A,i,j): A[i],A[j] = A[j],A[i] return A def isStable(A): for i in range(1, len(A)): if A[i][1] == A[i-1][1]: if A[i][2] < A[i-1][2]: return False return True def partition(A,p=0, r=None): if r is None: r = len(A)-1 x = A[r] i = p-1 fo...
s431487359
p02277
u426534722
1517237990
Python
Python3
py
Runtime Error
0
0
775
import sys readline = sys.stdin.readline 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, ...
s957918720
p02277
u177808190
1518527491
Python
Python3
py
Runtime Error
20
5620
1092
def partition(hoge, p, r): x = int(hoge[r-1][1]) i = p-1 for j in range(p, len(hoge)): if int(hoge[j][1]) <= x: i += 1 tmp = hoge[i] hoge[i] = hoge[j] hoge[j] = tmp return i def qSort(hoge, p, r): if p < r: q = partition(hoge, p, r...
s598690782
p02277
u150984829
1518841310
Python
Python3
py
Runtime Error
0
0
471
import sys def t(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 k(A,p,r): if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r) def s(A): for i in range(n-1): if A[i][1]==A[i+1][1]: if A[i][2]>A[i+1][2]:return 0 return 1 n=int(input()) f=lambda...
s130648760
p02277
u150984829
1518843458
Python
Python3
py
Runtime Error
0
0
445
import sys def t(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 k(A,p,r): if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r) def s(A): for i in range(n-1): if A[i][1]==A[i+1][1]and A[i][2]>A[i+1][2]:return'Not s' return'S' n=int(input()) A=[(e[...
s354904776
p02277
u150984829
1520051083
Python
Python3
py
Runtime Error
0
0
484
import sys def t(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 k(A,p,r): if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r) def s(A): for i in range(n-1): if A[i][1]==A[i+1][1]and A[i][2]>A[i+1][2]:return'Not s' return'S' def m(): n=int(input...
s668807896
p02277
u328199937
1524621695
Python
Python3
py
Runtime Error
20
5612
1246
def partition(A, left, right): p = left r = right x = A[r][1] i = p - 1 for j in range(p, r): if A[j][1] <= x: i += 1 key = A[i] A[i] = A[j] A[j] = key key = A[i + 1] A[i + 1] = A[r] A[r] = key if i + 1 - left <= 1: if r...
s489620411
p02277
u328199937
1524623224
Python
Python3
py
Runtime Error
20
5616
1245
def partition(A, left, right): p = left r = right x = A[r][1] i = p - 1 for j in range(p, r): if A[j][1] <= x: i += 1 key = A[i] A[i] = A[j] A[j] = key key = A[i + 1] A[i + 1] = A[r] A[r] = key if i + 1 - left <= 1: if r...
s793887808
p02277
u255317651
1525354073
Python
Python3
py
Runtime Error
20
5620
1038
# -*- coding: utf-8 -*- """ Created on Thu May 3 21:24:25 2018 ALDS1_6_C @author: maezawa """ a = [] n = int(input()) for i in range(n): s = input().split() a.append([s[0], int(s[1])]) a_in = a.copy() def is_stable(a, b): s = True for i, card in enumerate(b): if b[i+1][1] == b[i][1]: ...
s634911755
p02277
u684241248
1527768019
Python
Python3
py
Runtime Error
0
0
1426
INF = 10**10 def partition(ary, p, r): x = ary[r][1] i = p - 1 for j in range(p, r): if ary[j][1] <= x: i += 1 ary[i], ary[j] = ary[j], ary[i] ary[i + 1], ary[r] = ary[r], ary[i + 1] return i + 1 def quick_sort(ary, p, r): if p < r: q = partition(ary...
s348669463
p02277
u007270338
1528091966
Python
Python3
py
Runtime Error
30
6348
1142
#coding:utf-8 from copy import deepcopy n = int(input()) A = [] for i in range(n): ch, num = input().split() A.append([ch, int(num)]) B = deepcopy(A) def Merge(A, left, mid, right): L = A[left:mid] R = A[mid:right] L.append(["S",20000000]) R.append(["S",20000000]) i,j = 0,0 for k in ...
s575819031
p02277
u424720817
1530591818
Python
Python3
py
Runtime Error
0
0
399
n = int(input()) numbers = list(map(int, input().split())) def main() : x = numbers[n - 1] i = 0 for j in range(n) : if numbers[j] <= x : numbers[i], numbers[j] = numbers[j], numbers[i] i += 1 [print(numbers[j] if j != i - 1 else '['+str(numbers[j])+']', end = ' ' if j ...
s325639292
p02277
u912237403
1371352726
Python
Python
py
Runtime Error
20
4272
831
def partition(A, p, r): x = A[r]/10 i = p-1 for j in range(p, r): if A[j]/10 <= x: i += 1 A[i], A[j] = A[j], A[i] i += 1 A[i], A[r] = A[r], A[i] return i def quicksort(A, p, r): if p<r: q = partition(A, p, r) quicksort(A, p, q-1) quick...
s624856791
p02277
u912237403
1371365342
Python
Python
py
Runtime Error
0
0
846
def partition(A, p, r): x = A[r]/10 i = p-1 for j in range(p, r): if A[j]/10 <= x: i += 1 A[i], A[j] = A[j], A[i] i += 1 A[i], A[r] = A[r], A[i] print A,i,r return i def quicksort(A, p, r): if p<r: q = partition(A, p, r) quicksort(A, p, q-...
s862778680
p02278
u440050957
1454083178
Python
Python
py
Runtime Error
0
0
673
def get_weights(): input() return raw_input().split() #weights: list def minimam_cost_sort(weights): lol = [] for i in weights: if i !=0: j = i l = [j] while weights[j - 1] != 0: l.append(weights[j - 1]) j = weights[j - 1] ...
s550878983
p02278
u440050957
1454083967
Python
Python
py
Runtime Error
10
6408
766
def get_weights(): raw_input() return map(int, raw_input().split()) #weights: list def minimam_cost_sort(weights): lol = [] for i in range(len(weights)): if weights[i] !=0: j = weights[i] weights[i] = 0 l = [j] while weights[j - 1] != 0: ...
s327720666
p02278
u567281053
1459614983
Python
Python
py
Runtime Error
20
6548
686
import sys def minimumCostSort(A): B = sorted(A) V = [False] * len(A) T = [0] * 10000 ans = 0 s = min(A) for i in range(len(A)): T[B[i]] = i for i in range(len(A)): if V[i]: continue S = an = 0 j = i m = 10000 while True: ...
s374806663
p02278
u742013327
1478840293
Python
Python3
py
Runtime Error
20
7912
2401
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_D #????°??????????????????? def partition(target_list, l, r): x = target_list[r] i = l - 1 for j in range(l, r): if target_list[j] <= x: i = i + 1 tmp = target_list[i] target_list[i] = target_list[...
s618661055
p02278
u022407960
1479897472
Python
Python3
py
Runtime Error
20
7744
1141
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys MAX_VALUE = 1e4 def min_cost_sort(): ans = 0 for i in range(array_length): if check_order[i]: continue current_index = i _sum, min_value, circle_size = 0, MAX_VALUE, 0 while True: check_order[cur...
s813406616
p02278
u918276501
1508063320
Python
Python3
py
Runtime Error
0
0
767
def swap(A,i,j): A[i],A[j] = A[j],A[i] return A def mincost(A): B = sorted(A) cost = 0 for i, bi in enumerate(B): t = 0 j = A.index(bi) tmp_cost = 0 # swap in a cyclic group while j != i: t += 1 bj = B[j] k = ...
s019119332
p02278
u957470671
1511917819
Python
Python3
py
Runtime Error
20
5600
550
# line = "4 3 2 1" # L = [int(x) for x in line.split()] # n = len(L) n = int(input()) line = input() L = [int(x) for x in line.split()] flags = [False] * n loops = [] for i, x in enumerate(L): k = x - 1 if flags[k]: continue if i == k: flags[i] = True continue loop = [] w...
s416905491
p02278
u957470671
1511917903
Python
Python3
py
Runtime Error
20
5604
480
n = int(input()) line = input() L = [int(x) for x in line.split()] flags = [False] * n loops = [] for i, x in enumerate(L): k = x - 1 if flags[k]: continue if i == k: flags[i] = True continue loop = [] while x not in loop: flags[k] = True loop.append(x) ...
s466438584
p02278
u426534722
1517324830
Python
Python3
py
Runtime Error
0
0
579
n = int(input()) A = list(map(int, input().split())) s = min(A) def solve(): ans = 0 V = [False] * n # B = sorted(A) # T = {B[i]: i for i in range(n)} T = {B: i for i, B in enumerate(sorted(A))} for i in range(n): if V[i]: continue cur = i S = an = 0 m = ...
s404025644
p02278
u150984829
1518977988
Python
Python3
py
Runtime Error
0
0
226
n=int(input()) a=list(map(int, input().split())) b=sorted(a) c=0 for i in range(n): x=a.index(b[i]) j=0 while x > i: j+=1 y=a.index(b[x]) c+=a[b] a[x],a[y]=a[y],a[x] x=y c+=min(b[i]*j,b[i]*2+b[0]*(j+2)) print(c)
s676599596
p02278
u500386459
1519402405
Python
Python3
py
Runtime Error
0
0
1208
let quick_sort a n cmp = let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in let partition p r = let i = ref p in for j = p to r - 1 do if cmp a.(j) a.(r) <= 0 then (swap !i j; incr i) done; swap !i r; !i in let rec doit p r = if p >= r then () else let q = partitio...
s092462832
p02278
u500386459
1519402412
Python
Python
py
Runtime Error
0
0
1208
let quick_sort a n cmp = let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in let partition p r = let i = ref p in for j = p to r - 1 do if cmp a.(j) a.(r) <= 0 then (swap !i j; incr i) done; swap !i r; !i in let rec doit p r = if p >= r then () else let q = partitio...
s561586851
p02278
u138546245
1524566688
Python
Python3
py
Runtime Error
20
5648
2243
def partition(li, p, r): """Separate li with a value of li[r]. Returns index of the partition value. >>> ax = [13, 19, 9, 5, 12, 8, 7, 4, 21, 2, 6, 11] >>> partition(ax, 0, 11) 7 >>> ax [9, 5, 8, 7, 4, 2, 6, 11, 21, 13, 19, 12] """ x = li[r] i = p - 1 for j in range(p, r): ...
s538963761
p02278
u318430977
1528817706
Python
Python3
py
Runtime Error
20
5612
1290
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 i + 1 def quick_sort(a, p, r): if p < r: q = partition(a,...
s616023301
p02278
u318430977
1528817986
Python
Python3
py
Runtime Error
30
5624
1392
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 i + 1 def quick_sort(a, p, r): if p < r: q = partition(a,...
s875012938
p02279
u153665391
1531230222
Python
Python3
py
Runtime Error
0
0
1525
N = int(input()) def get_parent(node): parent = -1 if "parent" in node: parent = node["parent"] return parent def get_depth(node): depth = 0 while "parent" not in node: depth += 1 parent = node["parent"] node = rooted_tree[parent] return depth def get_node_type...
s118951374
p02279
u153665391
1531436040
Python
Python3
py
Runtime Error
20
5612
1701
N = int(input()) def get_parent(node): parent = -1 if "parent" in node: parent = node["parent"] return parent def get_node_type(node): if "parent" not in node: return "root" if "left" not in node: return "leaf" return "internal node" def get_children(node): if "lef...
s411722048
p02279
u657361950
1531707092
Python
Python3
py
Runtime Error
0
0
2011
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { static class Node { int id; int parentId; int depth; int[] children; public Node(int id, int parentId) { this.id = id; this.paren...
s603592848
p02279
u657361950
1531790943
Python
Python3
py
Runtime Error
0
0
1349
class Node: def __init__(self, id): self.id = id self.parent_id = -1 self.depth = -1 self.children = None def get_type(self): if self.parent_id == -1: return 'root' elif self.children == None or len(self.children) == 0: return 'leaf' return 'internal node' def __str__(self): strNode = 'node ' +...
s474523829
p02279
u637322311
1535099929
Python
Python3
py
Runtime Error
20
5612
1125
from sys import stdin class Node(object): def __init__(self, parent=None, children=None, name=None, depth=None): self.parent = parent self.children = children self.name = name self.depth = depth def set_depth(nodes, u): p = nodes[u].parent d = nodes[p].depth if d != Non...
s016238642
p02279
u487861672
1535698209
Python
Python3
py
Runtime Error
20
5608
898
#! /usr/local/bin/python3 # coding: utf-8 class Node(): def __init__(self, parent=-1, child=[]): self.parent = parent self.child = child def node_depth(u, id): if u[id].parent == -1: return 0 else: return node_depth(u, u[id].parent) + 1 def node_type(u, id): if u[id...
s077990586
p02279
u487861672
1535698304
Python
Python3
py
Runtime Error
20
5616
987
#! /usr/local/bin/python3 # coding: utf-8 from sys import setrecursionlimit setrecursionlimit(21) class Node(): def __init__(self, parent=-1, child=[]): self.parent = parent self.child = child def node_depth(u, id): if u[id].parent == -1: return 0 else: return node_dept...
s356769780
p02279
u487861672
1535698327
Python
Python3
py
Runtime Error
20
5620
987
#! /usr/local/bin/python3 # coding: utf-8 from sys import setrecursionlimit setrecursionlimit(22) class Node(): def __init__(self, parent=-1, child=[]): self.parent = parent self.child = child def node_depth(u, id): if u[id].parent == -1: return 0 else: return node_dept...
s510482477
p02279
u487861672
1535975339
Python
Python3
py
Runtime Error
20
5616
1410
class Node(): NIL = -1 def __init__(self, parent=NIL, left=NIL, right=NIL, depth=-1): self.parent = parent self.left = left self.right = right self.depth = depth def read_nodes(T): for _ in range(len(T)): id, _, *child = [int(x) for x in input().split()] for...
s766638627
p02279
u487861672
1535975667
Python
Python3
py
Runtime Error
0
0
1481
from sys import setrecursionlimit setrecursionlimit(1000) class Node(): NIL = -1 def __init__(self, parent=NIL, left=NIL, right=NIL, depth=-1): self.parent = parent self.left = left self.right = right self.depth = depth def read_nodes(T): for _ in range(len(T))...
s195783752
p02279
u487861672
1535975690
Python
Python3
py
Runtime Error
20
5620
1472
from sys import setrecursionlimit setrecursionlimit(1000) class Node(): NIL = -1 def __init__(self, parent=NIL, left=NIL, right=NIL, depth=-1): self.parent = parent self.left = left self.right = right self.depth = depth def read_nodes(T): for _ in range(len(T)): ...
s780475739
p02279
u487861672
1535975734
Python
Python3
py
Runtime Error
20
5620
1474
from sys import setrecursionlimit setrecursionlimit(200000) class Node(): NIL = -1 def __init__(self, parent=NIL, left=NIL, right=NIL, depth=-1): self.parent = parent self.left = left self.right = right self.depth = depth def read_nodes(T): for _ in range(len(T)): ...
s153622781
p02279
u487861672
1535976010
Python
Python3
py
Runtime Error
20
5616
1474
from sys import setrecursionlimit setrecursionlimit(100000) class Node(): NIL = -1 def __init__(self, parent=NIL, left=NIL, right=NIL, depth=-1): self.parent = parent self.left = left self.right = right self.depth = depth def read_nodes(T): for _ in range(len(T)): ...
s256653212
p02279
u487861672
1535976026
Python
Python3
py
Runtime Error
20
5616
1473
from sys import setrecursionlimit setrecursionlimit(50000) class Node(): NIL = -1 def __init__(self, parent=NIL, left=NIL, right=NIL, depth=-1): self.parent = parent self.left = left self.right = right self.depth = depth def read_nodes(T): for _ in range(len(T)): ...
s891273863
p02279
u487861672
1535976049
Python
Python3
py
Runtime Error
30
5620
1473
from sys import setrecursionlimit setrecursionlimit(99999) class Node(): NIL = -1 def __init__(self, parent=NIL, left=NIL, right=NIL, depth=-1): self.parent = parent self.left = left self.right = right self.depth = depth def read_nodes(T): for _ in range(len(T)): ...
s084869984
p02279
u609159835
1546151307
Python
Python3
py
Runtime Error
0
0
1427
#include<stdio.h> #include<stdlib.h> #define MAX 100000 #define NIL -1 typedef struct node { int p; int l; int r; } Node; Node no[MAX]; int D[MAX]; void setDepth(int u, int p){ D[u] = p; if(no[u].l != NIL){ setDepth(no[u].l, p + 1); } if (no[u].r != NIL){ setDepth(no[u]...
s467622726
p02279
u631142478
1559360041
Python
Python3
py
Runtime Error
20
5620
1038
class Node(): def __init__(self, p, l, r): self.p = p self.l = l self.r = r def rec(u, p): D[u] = p if T[u].r != -1: rec(T[u].r, p) if T[u].l != -1: rec(T[u].l, p + 1) N = int(input()) T = [Node(-1, -1, -1) for _ in range(N)] D = [-1] * N for i in range(N): ...
s235773555
p02279
u631142478
1559360112
Python
Python3
py
Runtime Error
20
5624
1080
import sys sys.setrecursionlimit(10000) class Node(): def __init__(self, p, l, r): self.p = p self.l = l self.r = r def rec(u, p): D[u] = p if T[u].r != -1: rec(T[u].r, p) if T[u].l != -1: rec(T[u].l, p + 1) N = int(input()) T = [Node(-1, -1, -1) for _ in ra...
s086467730
p02279
u631142478
1559360131
Python
Python3
py
Runtime Error
20
5624
1081
import sys sys.setrecursionlimit(100000) class Node(): def __init__(self, p, l, r): self.p = p self.l = l self.r = r def rec(u, p): D[u] = p if T[u].r != -1: rec(T[u].r, p) if T[u].l != -1: rec(T[u].l, p + 1) N = int(input()) T = [Node(-1, -1, -1) for _ in r...
s592896594
p02279
u567380442
1421820075
Python
Python3
py
Runtime Error
0
0
1370
class Tree(): def __init__(self, root_id): self.nodes = {root_id:Node(root_id)} def add_node(self, parent_id, child_id): child = Node(child_id, self.nodes[parent_id]) self.nodes[child.id] = child class Node(): def __init__(self, id, parent = None): self.id = id s...
s645412441
p02279
u567380442
1421820259
Python
Python3
py
Runtime Error
30
6752
1377
class Tree(): def __init__(self, root_id): self.nodes = {root_id:Node(root_id)} def add_node(self, parent_id, child_id): child = Node(child_id, self.nodes[parent_id]) self.nodes[child.id] = child class Node(): def __init__(self, id, parent = None): self.id = id s...
s457390630
p02279
u253463900
1445866965
Python
Python3
py
Runtime Error
40
7784
1638
def Get_leafs_list(T, p): l = p.l ans = [] while(T[l].r != -1): ans.append(T[l].r) l = T[l].r return ans def rec(T,node, p): T[node].d = p if(T[node].r != -1): rec(T,T[node].r, p) if(T[node].l != -1): rec(T,T[node].l, p+1) class Node(): def __init__(sel...
s126259604
p02279
u881590806
1448767798
Python
Python
py
Runtime Error
20
6416
1328
class Node: def __init__(self, parent, left, right): self.parent = parent self.left = left self.right = right def get_type(self): if self.parent == -1: return "root" elif self.left == -1: return "leaf" else: return "internal node" def set_depth(u,d): global ...
s122212381
p02279
u881590806
1448874506
Python
Python
py
Runtime Error
10
6500
1336
class Node: def __init__(self, parent, left, right): self.parent = parent self.left = left self.right = right def get_type(self): if self.parent == -1: return "root" elif self.left == -1: return "leaf" else: return "internal node" def set_depth(u,d): global ...
s809884429
p02279
u881590806
1448874959
Python
Python
py
Runtime Error
10
6332
1346
class Node: def __init__(self, parent, left, right): self.parent = parent self.left = left self.right = right def get_type(self): if self.parent == -1: return "root" elif self.left == -1: return "leaf" else: return "internal node" def set_depth(u,d): global ...
s602830499
p02279
u797673668
1454172466
Python
Python3
py
Runtime Error
20
7744
1134
n = int(input()) tree = [None] * n formatted_tree = [None] * n def register_node(i, node, searching): if not searching: return False for si, st in enumerate(searching[1]): if st[0] == i: searching[1][si] = node return True elif st[1]: if register_nod...
s582912421
p02279
u072053884
1454781859
Python
Python3
py
Runtime Error
30
7804
1798
"""Rooted Trees.""" class Node: def __init__(self, num, parent, rightSibling, *children): self.id = num self.parent = parent self.rightSibling = rightSibling self.children = list(children) self.depth = 0 def showInfo(self): print('node {0}: '.format(self.id), end...
s504083169
p02279
u072053884
1454783019
Python
Python3
py
Runtime Error
20
7868
1813
"""Rooted Trees.""" class Node: def __init__(self, num, parent, rightSibling, *children): self.id = num self.parent = parent self.rightSibling = rightSibling self.children = list(children) self.depth = 0 def showInfo(self): print('node {0}: '.format(self.id), end...
s584455858
p02279
u072053884
1454783492
Python
Python3
py
Runtime Error
660
90272
1844
"""Rooted Trees.""" class Node: def __init__(self, num, parent, rightSibling, *children): self.id = num self.parent = parent self.rightSibling = rightSibling self.children = list(children) self.depth = 0 def showInfo(self): print('node {0}: '.format(self.id), end...
s098971326
p02279
u072053884
1454783544
Python
Python3
py
Runtime Error
570
90472
1845
"""Rooted Trees.""" class Node: def __init__(self, num, parent, rightSibling, *children): self.id = num self.parent = parent self.rightSibling = rightSibling self.children = list(children) self.depth = 0 def showInfo(self): print('node {0}: '.format(self.id), end...
s695448265
p02279
u341533698
1454852279
Python
Python
py
Runtime Error
10
6488
1401
import sys n = int(raw_input()) #class of node class Node: def __init__(self): self.p = -1 self.l = -1 self.r = -1 T = [ Node() for _ in xrange(n)] #info of u D = [0] * n #depth of u def printInfo(u): #print 'node', u, ':', #print 'parent = ', T[u].p, ',', #print 'depth = ',...
s312818756
p02279
u247976584
1454910478
Python
Python3
py
Runtime Error
30
8184
1579
from collections import deque, namedtuple class RootedTree: def __init__(self, t, n): self.t = t self.n = n self.d = [-1] * n def setDepth(self, u, p): self.d[u] = p if self.t[u].r != -1: self.setDepth(self.t[u].r, p) if self.t[u].l != -1: ...
s536717301
p02279
u247976584
1454910836
Python
Python3
py
Runtime Error
30
8204
1619
from collections import deque, namedtuple import sys sys.setrecursionlimit(10000) class RootedTree: def __init__(self, t, n): self.t = t self.n = n self.d = [-1] * n def setDepth(self, u, p): self.d[u] = p if self.t[u].r != -1: self.setDepth(self.t[u].r, p) ...
s470088129
p02279
u247976584
1454910942
Python
Python3
py
Runtime Error
1060
63832
1620
from collections import deque, namedtuple import sys sys.setrecursionlimit(100000) class RootedTree: def __init__(self, t, n): self.t = t self.n = n self.d = [-1] * n def setDepth(self, u, p): self.d[u] = p if self.t[u].r != -1: self.setDepth(self.t[u].r, p) ...
s282886033
p02279
u247976584
1454911142
Python
Python3
py
Runtime Error
1080
63852
1621
from collections import deque, namedtuple import sys sys.setrecursionlimit(1000000) class RootedTree: def __init__(self, t, n): self.t = t self.n = n self.d = [-1] * n def setDepth(self, u, p): self.d[u] = p if self.t[u].r != -1: self.setDepth(self.t[u].r, p)...
s229368194
p02279
u247976584
1454911342
Python
Python3
py
Runtime Error
1080
63404
1623
from collections import deque, namedtuple import sys sys.setrecursionlimit(100000000) class RootedTree: def __init__(self, t, n): self.t = t self.n = n self.d = [-1] * n def setDepth(self, u, p): self.d[u] = p if self.t[u].r != -1: self.setDepth(self.t[u].r, ...
s658952893
p02279
u247976584
1454911545
Python
Python3
py
Runtime Error
1070
63844
1619
from collections import deque, namedtuple import sys sys.setrecursionlimit(1000000000) class RootedTree: def __init__(self, t, n): self.t = t self.n = n self.d = [-1] * n def setDepth(self, u, p): self.d[u] = p if self.t[u].r != -1: self.setDepth(self.t[u].r,...
s699996899
p02279
u963402991
1459994124
Python
Python3
py
Runtime Error
0
0
999
class Node: def __init__(self, num, parent, children): self.id = num self.parent = -1 self.depth = 0 self.type = None self.children = children def show_info(self): print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.id, self.parent, self.depth,self...
s476940978
p02279
u317901693
1477022668
Python
Python3
py
Runtime Error
0
0
1603
# -*- coding: utf-8 -*- class Node(object): # left????????¨??????????????????(leaf), right???s?????¨?????????????????????????????? # ???????????????????????????????????¨???????????´??????parent???-1????????? def __init__(self, N): self.p = [-1 for i in range(N)] self.l = [-1 for i in range(...
s074616888
p02279
u317901693
1477022784
Python
Python3
py
Runtime Error
0
0
1303
class Node(object): def __init__(self, N): self.p = [-1 for i in range(N)] self.l = [-1 for i in range(N)] self.r = [-1 for i in range(N)] self.D = [-1 for i in range(N)] def set_depth(self, u, p): self.D[u] = p if self.r[u] is not -1: self.set_depth(...
s562523852
p02279
u317901693
1477022822
Python
Python3
py
Runtime Error
0
0
1251
class Node(object): def __init__(self, N): self.p = [-1 for i in range(N)] self.l = [-1 for i in range(N)] self.r = [-1 for i in range(N)] self.D = [-1 for i in range(N)] def set_depth(self, u, p): self.D[u] = p if self.r[u] is not -1: self.set_depth(...
s155269556
p02279
u317901693
1477023278
Python
Python3
py
Runtime Error
0
0
1264
class Node(object): def __init__(self, N): self.p = [-1 for i in range(N)] self.l = [-1 for i in range(N)] self.r = [-1 for i in range(N)] self.D = [-1 for i in range(N)] def set_depth(self, u, p): self.D[u] = p if self.r[u] is not -1: self.set_depth...
s206480495
p02279
u317901693
1477024099
Python
Python3
py
Runtime Error
20
7792
1522
# -*- coding: utf-8 -*- class Node(object): # left????????¨??????????????????(leaf), right???s?????¨?????????????????????????????? # ???????????????????????????????????¨???????????´??????parent???-1????????? def __init__(self, N): self.p = [-1 for i in range(N)] self.l = [-1 for i in range(...
s721720362
p02279
u317901693
1477032244
Python
Python3
py
Runtime Error
0
0
1562
# -*- coding: utf-8 -*- import sys sys.getrecursionlimit(10000) class Node(object): # left????????¨??????????????????(leaf), right???s?????¨?????????????????????????????? # ???????????????????????????????????¨???????????´??????parent???-1????????? def __init__(self, N): self.p = [-1 for i in range(N...
s601939799
p02279
u317901693
1477032355
Python
Python3
py
Runtime Error
30
7844
1563
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10000) class Node(object): # left????????¨??????????????????(leaf), right???s?????¨?????????????????????????????? # ???????????????????????????????????¨???????????´??????parent???-1????????? def __init__(self, N): self.p = [-1 for i in range...
s276554044
p02279
u811733736
1480917355
Python
Python3
py
Runtime Error
0
0
2133
class Node(object): def __init__(self, parent, left, right): self.parent = parent # ???????????? self.left = left # ?????????????????????????????????????????? self.right = right # ??????????????????????????????????????´????????? def get_depth(self): if self.parent == No...
s493841072
p02279
u811733736
1480917631
Python
Python3
py
Runtime Error
30
7820
2195
class Node(object): def __init__(self, parent, left, right): self.parent = parent # ???????????? self.left = left # ?????????????????????????????????????????? self.right = right # ??????????????????????????????????????´????????? def get_depth(self): if self.parent == -...
s035135719
p02279
u923668099
1484735458
Python
Python3
py
Runtime Error
20
7872
1296
import sys nil = -1 class Node: def __init__(self, p, l, r): self.p = p self.l = l self.r = r def depth_rec(u, p, depth): depth[u] = p if tree[u].r != nil: depth_rec(tree[u].r, p, depth) if tree[u].l != nil: depth_rec(tree[u].l, p + 1, depth) pass n = int(...
s160063647
p02279
u923668099
1484735617
Python
Python3
py
Runtime Error
550
72936
1327
import sys sys.setrecursionlimit(10 ** 6) nil = -1 class Node: def __init__(self, p, l, r): self.p = p self.l = l self.r = r def depth_rec(u, p, depth): depth[u] = p if tree[u].r != nil: depth_rec(tree[u].r, p, depth) if tree[u].l != nil: depth_rec(tree[u].l, p...
s045446283
p02279
u923668099
1484735679
Python
Python3
py
Runtime Error
520
72808
1327
import sys sys.setrecursionlimit(10 ** 8) nil = -1 class Node: def __init__(self, p, l, r): self.p = p self.l = l self.r = r def depth_rec(u, p, depth): depth[u] = p if tree[u].r != nil: depth_rec(tree[u].r, p, depth) if tree[u].l != nil: depth_rec(tree[u].l, p...
s084862864
p02279
u923668099
1484735830
Python
Python3
py
Runtime Error
510
72812
1327
import sys sys.setrecursionlimit(10 ** 9) nil = -1 class Node: def __init__(self, p, l, r): self.p = p self.l = l self.r = r def depth_rec(u, p, depth): depth[u] = p if tree[u].r != nil: depth_rec(tree[u].r, p, depth) if tree[u].l != nil: depth_rec(tree[u].l, p...
s462681322
p02279
u564398841
1486285587
Python
Python3
py
Runtime Error
0
0
1187
fin = open('sample.txt') input = fin.readline def main(): N = int(input()) A = [0] * N node_info = [[-1, 0, 'internal node', None] for _ in range(int(1E5 + 1))] for i in range(N): A[i] = [int(i) for i in input().strip().split()] for line in A: if line[1] != 0: node_info...