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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s913592298 | p02281 | u626266743 | 1511268069 | Python | Python3 | py | Runtime Error | 0 | 0 | 722 | n = int(input())
tree = [None for i in range(n)]
root = set(range(n))
for i in range(n):
i, l, r = map(int, input().split())
left[i] = l
right[i] = r
root -= {1, r}
def preorder(i):
if (i == -1):
return
print(" {}".format(i), end = "")
preorder(left[i])
preorder(right[i])
... |
s138941615 | p02281 | u626266743 | 1511268125 | Python | Python3 | py | Runtime Error | 0 | 0 | 785 | n = int(input())
tree = [None for i in range(n)]
root = set(range(n))
for i in range(n):
i, l, r = map(int, input().split())
left[i] = l
right[i] = r
root -= {1, r}
def preorder(i):
if (i == -1):
return
(l, r) = tree[i]
print(" {}".format(i), end = "")
preorder(left[i])
pre... |
s618567103 | p02281 | u626266743 | 1511268222 | Python | Python3 | py | Runtime Error | 0 | 0 | 756 | n = int(input())
left = [None for i in range(n)]
right = [None for i in range(n)]
root = set(range(n))
for i in range(n):
i, l, r = map(int, input().split())
left[i] = l
right[i] = r
root -= (1 + r)
def preorder(i):
if (i == -1):
return
print(" {}".format(i), end = "")
preorder(lef... |
s704750874 | p02281 | u626266743 | 1511268270 | Python | Python3 | py | Runtime Error | 0 | 0 | 756 | n = int(input())
left = [None for i in range(n)]
right = [None for i in range(n)]
root = set(range(n))
for i in range(n):
i, l, r = map(int, input().split())
left[i] = l
right[i] = r
root -= (l + r)
def preorder(i):
if (i == -1):
return
print(" {}".format(i), end = "")
preorder(lef... |
s157419660 | p02281 | u626266743 | 1511268337 | Python | Python3 | py | Runtime Error | 0 | 0 | 756 | n = int(input())
left = [None for i in range(n)]
right = [None for i in range(n)]
root = set(range(n))
for i in range(n):
i, l, r = map(int, input().split())
left[i] = l
right[i] = r
root -= (l + r)
def Preorder(i):
if (i == -1):
return
print(" {}".format(i), end = "")
Preorder(lef... |
s904397671 | p02281 | u626266743 | 1511268406 | Python | Python3 | py | Runtime Error | 0 | 0 | 756 | n = int(input())
left = [None for i in range(n)]
right = [None for i in range(n)]
root = sum(range(n))
for i in range(n):
i, l, r = map(int, input().split())
left[i] = l
right[i] = r
root -= (l + r)
def Preorder(i):
if (i == -1):
return
print(" {}".format(i), end = "")
Preorder(lef... |
s806470884 | p02281 | u424457654 | 1511277455 | Python | Python3 | py | Runtime Error | 0 | 0 | 694 | n = int(input())
left = [None for i in range(n)]
right = [None for i in range(n)]
root = set(range(n))
for i in range(n):
i, l, r = map(int, input().split())
left[i] = l
right[i] = r
root -= {l, r}
def Preorder(i):
if i == -1:
return
print(" {}".format(i), end = "")
Preorder(left[i... |
s225573518 | p02281 | u424457654 | 1511277580 | Python | Python3 | py | Runtime Error | 0 | 0 | 794 | n = int(input())
left = [None for i in range(n)]
right = [None for i in range(n)]
root = set(range(n))
for i in range(n):
i, l, r = map(int, input().split())
left[i] = l
right[i] = r
root -= {l, r}
def Preorder(i):
if i == -1:
return
(l, r) = tree[i]
print(" {}".format(i), end = ""... |
s215454602 | p02281 | u424457654 | 1511277644 | Python | Python3 | py | Runtime Error | 0 | 0 | 825 | n = int(input())
left = [None for i in range(n)]
right = [None for i in range(n)]
root = set(range(n))
for i in range(n):
i, l, r = map(int, input().split())
left[i] = l
right[i] = r
root -= {l, r}
root_n = root.pop()
def Preorder(i):
if i == -1:
return
(l, r) = tree[i]
print(... |
s281438885 | p02281 | u424457654 | 1511277859 | Python | Python3 | py | Runtime Error | 0 | 0 | 762 | n = int(input())
left = [None for _ in range(n)]
right = [None for _ in range(n)]
root = set(range(n))
for i in range(n):
i, l, r = map(int, input().split())
left[i] = l
right[i] = r
root -= {l, r}
root_n = root.pop()
def Preorder(i):
if i == -1:
return
print(" {}".format(i), end ... |
s021139801 | p02281 | u150984829 | 1519145436 | Python | Python3 | py | Runtime Error | 0 | 0 | 371 | def p(u):
if u+1:print(s,u,end=s);p(T[u]);p(T[u+N])
def i(u):
if u+1:i(T[u]);print(s,u,end=s);i(T[u+N])
def o(u):
if u+1:o(T[u]);o(T[u+N]);print(s,u,end=s)
s,o='','order'
N=int(input())
T=[0,0]*N
R=set(range(N))
for _ in[0]*N:
a,b,c=map(int,input().split())
T[a],T[a+N]=b,c
R-={b,c}
r=R.pop()
print('Pre'+o)
p(r)
p... |
s060925120 | p02281 | u912143677 | 1521842159 | Python | Python3 | py | Runtime Error | 0 | 0 | 795 | NIL = -1
class Node:
parent = NIL
left = NIL
right = NIL
n = int(input())
t = [Node for i in range(n)]
for i in range(n):
tmp = list(map(int, input().split()))
if tmp[1] != -1:
t[i].left = tmp[1]
t[tmp[1]].parent = i
if tmp[2] != -1:
t[i].right = tmp[2]
t[tmp[2... |
s726245600 | p02281 | u912143677 | 1521843736 | Python | Python3 | py | Runtime Error | 0 | 0 | 858 | NIL = -1
class Node:
def __init__(self):
self.parent = NIL
self.left = NIL
self.right = NIL
n = int(input())
t = [Node() for i in range(n)]
for i in range(n):
tmp = list(map(int, input().split()))
if tmp[1] != -1:
t[i].left = tmp[1]
t[tmp[1]].parent = i
if tmp... |
s593563405 | p02281 | u912143677 | 1521843879 | Python | Python3 | py | Runtime Error | 0 | 0 | 878 | NIL = -1
class Node:
def __init__(self):
self.parent = NIL
self.left = NIL
self.right = NIL
n = int(input())
t = [Node() for i in range(n)]
for i in range(n):
tmp = list(map(int, input().split()))
if tmp[1] != -1:
t[i].left = tmp[1]
t[tmp[1]].parent = i
if tmp... |
s823935385 | p02281 | u007270338 | 1529778379 | Python | Python3 | py | Runtime Error | 0 | 0 | 1562 | #coding:utf-8
N = int(input())
class Tree:
def __init__(self, ID,p=-1):
self.ID = ID
def makeTree(self, tree):
ID = tree.ID
if ID == -1:
return
else:
[ID,l,r] = trees[ID]
tree.l = Tree(l)
tree.r = Tree(r)
treeL = tree.... |
s783945505 | p02281 | u782850731 | 1380159757 | Python | Python | py | Runtime Error | 20 | 4340 | 1452 | #!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
class Node(object):
def __init__(self):
self.id = None
self.parent = -1
self.childs = None
def preorder_walk(data, index, out):
node = data[index]
out.append(node.id)
for cidx in node.... |
s882684352 | p02282 | u805716376 | 1556808837 | Python | Python3 | py | Runtime Error | 0 | 0 | 297 | n = int(input())
pre = list(map(int, input().split()))
ino = list(map(int, input().split()))
d = []
root = pre[1]
pre = iter(pre).__next__
def dfs(l, r):
if l >= r:
return
c = pre()
m = ino.index(c)
dfs(l, m)
dfs(m+1, r)
d += [c]
dfs(0, len(ino))
print(*c)
|
s358572571 | p02282 | u805716376 | 1556808861 | Python | Python3 | py | Runtime Error | 0 | 0 | 297 | n = int(input())
pre = list(map(int, input().split()))
ino = list(map(int, input().split()))
d = []
root = pre[1]
pre = iter(pre).__next__
def dfs(l, r):
if l >= r:
return
c = pre()
m = ino.index(c)
dfs(l, m)
dfs(m+1, r)
d += [c]
dfs(0, len(ino))
print(*d)
|
s448542251 | p02282 | u805716376 | 1556808922 | Python | Python3 | py | Runtime Error | 20 | 5600 | 310 | n = int(input())
pre = list(map(int, input().split()))
ino = list(map(int, input().split()))
d = []
root = pre[1]
pre = iter(pre).__next__
def dfs(l, r):
global d
if l >= r:
return
c = pre()
m = ino.index(c)
dfs(l, m)
dfs(m+1, r)
d += [c]
dfs(0, len(ino))
print(*d)
|
s135645222 | p02282 | u881590806 | 1469449250 | Python | Python | py | Runtime Error | 10 | 6404 | 1090 | def postorder(n,preorder,inorder):
if len(preorder) > 1:
left_inorder = []
right_inorder = []
flag = False
for i in range(len(inorder)):
if flag == False:
if n == inorder[i]:
flag = True
else:
left_in... |
s192067775 | p02282 | u159356473 | 1478849579 | Python | Python3 | py | Runtime Error | 20 | 7764 | 448 | #coding:UTF-8
def RoT(A,B,ans):
if A:
root=A[0]
rindex=B.index(root)
Aleft=A[1:rindex+1]
Aright=A[rindex+1:]
Bleft=B[:rindex]
Bright=B[rindex:]
RoT(Aleft,Bleft,ans)
RoT(Aright,Bright,ans)
ans.append(root)
if __name__=="__ma... |
s234426509 | p02282 | u742013327 | 1479114641 | Python | Python3 | py | Runtime Error | 20 | 7768 | 1565 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_D
def postorder(binary_tree, target_index, result):
left = binary_tree[target_index]["left"]
right = binary_tree[target_index]["right"]
if not left == -1:
postorder(binary_tree, left, result)
if not right == -1:
... |
s736108789 | p02282 | u742013327 | 1479115038 | Python | Python3 | py | Runtime Error | 20 | 7808 | 1594 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_D
def postorder(binary_tree, target_index, result):
left = binary_tree[target_index]["left"]
right = binary_tree[target_index]["right"]
if not left == -1:
postorder(binary_tree, left, result)
if not right == -1:
... |
s573211672 | p02282 | u603049633 | 1496319124 | Python | Python3 | py | Runtime Error | 0 | 0 | 374 | #Reconstruction of the Tree
n = int(input())
pre = list(map(int,input().split()))
ino = list(map(int,input().split()))
post=[]
i = -1
def recaonstruction(l, r):
global i
if l >= r:
return
i += 1
c = pre[i]
m = ino.index(c)
reconstruction(l, m)
reconstruction(m+1, r)
post.append(... |
s404319648 | p02282 | u533883485 | 1499157741 | Python | Python3 | py | Runtime Error | 0 | 0 | 658 | # coding=utf-8
from collections import deque
def reconstruction(left, right):
global pre_order
global in_order
global post_order
global n
if left > right:
return None
elif left == right:
root = pre_order.popleft()
post_order.append(root)
return None
else:
... |
s110495984 | p02282 | u533883485 | 1499157865 | Python | Python3 | py | Runtime Error | 0 | 0 | 658 | # coding=utf-8
from collections import deque
def reconstruction(left, right):
global pre_order
global in_order
global post_order
global n
if left > right:
return None
elif left == right:
root = pre_order.popleft()
post_order.append(root)
return None
else:
... |
s114150247 | p02282 | u193453446 | 1502171861 | Python | Python3 | py | Runtime Error | 0 | 0 | 1604 | I = 0
L = 1
R = 2
P = 3
B = 4
D = 5
H = 6
def search(N, A, B, num):
""" N ??? Nodes A???Preorder?????? B???Inorder??????
??????????????????????????§??? root ??? index ????????? """
# print(A)
# print(B)
root = A[0]
ld = num
for i in range(num):
if B[i] == root:
ld = i
... |
s341251132 | p02282 | u193453446 | 1502175299 | Python | Python3 | py | Runtime Error | 0 | 0 | 1432 | I = 0
L = 1
R = 2
P = 3
B = 4
D = 5
H = 6
def getidx(Tree,value):
idx = -1
for i in range(len(Tree)):
if Tree[i][I] == value:
idx = i
break
return idx
def search(Tree, A, B, num):
""" Tree ??? Tree A???Preorder?????? B???Inorder??????
??????????????????????????§... |
s567997852 | p02282 | u024715419 | 1509957030 | Python | Python3 | py | Runtime Error | 0 | 0 | 666 | n = int(input())
tree = [None for i in range(n +1)]
list_pre = list(map(int, input().split()))
list_in = list(map(int, input().split()))
def reconstruct(tree_pre, tree_in):
if not tree_pre:
return -1
root = tree_pre[0]
idx = tree_in.index(root)
tree[root] = (reconstruct(tree_pre[1:i + 1], tr... |
s420523179 | p02282 | u007270338 | 1529801548 | Python | Python3 | py | Runtime Error | 30 | 5604 | 394 | #coding:utf-8
N = int(input())
preList = "".join(list(input().split()))
inList = "".join(list(input().split()))
def recon(l,r):
if l >= r:
return
global pos
c = preList[pos]
index = inList.find(c)
pos += 1
recon(l,index)
recon(index+1,r)
global answer
answer.append(c)
... |
s924136271 | p02283 | u292798607 | 1531210169 | Python | Python3 | py | Runtime Error | 0 | 0 | 1652 | %%cython
class Node:
def __init__(self,x):
self.key = x
self.left = None
self.right = None
def insert(node, x):
if node is None:
return Node(x)
elif x == node.key:
return node
elif x < node.key:
node.left = insert(node.left, x)
else:
node.righ... |
s567180540 | p02283 | u292798607 | 1531210371 | Python | Python3 | py | Runtime Error | 0 | 0 | 1148 | #include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
struct Node {
int key;
Node *right, *left, *parent;
};
Node *root,*NIL;
void insert(int k){
Node *y = NIL;
Node *x = root;
Node *z;
z = (Node *)malloc(sizeof(Node));
z->key = k;
z->left = NIL;
z->right ... |
s585111046 | p02283 | u292798607 | 1531265327 | Python | Python3 | py | Runtime Error | 0 | 0 | 2143 | #include<cstdio>
#include<cstdlib>
#include<string>
#include<vector>
#include<iostream>
using namespace std;
struct Node {
int key;
Node *right, *left, *parent;
};
Node *root,*NIL;
bool exist = false;
vector<bool> v;
void insert(int k){
Node *y = NIL;
Node *x = root;
Node *z;
z = (Node *)malloc(sizeof(N... |
s674206974 | p02283 | u269568674 | 1531739569 | Python | Python3 | py | Runtime Error | 0 | 0 | 1253 | class binaryTree:
def __init__(self,key,p=None,l=None,r=None):
self.key = key
self.p = p
self.l = l
self.r = r
N = int(input())
treelist = [list(input().split()) for i in range(N)]
root = None
def inorder(root):
x = root
if x == None:
return
inorder(x.l)
... |
s283594810 | p02283 | u798803522 | 1540187163 | Python | Python3 | py | Runtime Error | 0 | 0 | 1945 |
from io import StringIO
class BinaryTree:
class Node:
def __init__(self, key):
self.key = key
self.left = None
self.right = None
self.parent = None
def __init__(self):
self.root = None
self.output = StringIO()
def insert(self, key... |
s800103695 | p02283 | u798803522 | 1540187319 | Python | Python3 | py | Runtime Error | 0 | 0 | 2003 | class BinaryTree:
from io import StringIO
class Node:
def __init__(self, key):
self.key = key
self.left = None
self.right = None
self.parent = None
def __init__(self):
self.root = None
self.output = StringIO()
def insert(se... |
s014652690 | p02283 | u677096240 | 1546310854 | Python | Python3 | py | Runtime Error | 20 | 5612 | 1694 | class Node:
key = None
left = None
right = None
def __init__(self, k):
self.key = k
class BST:
root = None
def insert(self, k):
x = self.root
y = None
z = Node(k)
while x is not None:
y = x
if z.key < y.key:
x = x.left
elif y.key < z.key:
x = x.right
... |
s818826327 | p02283 | u677096240 | 1546317825 | Python | Python3 | py | Runtime Error | 0 | 0 | 1155 | import re
class Node:
key = None
left = None
right = None
def __init__(self, k):
self.key = k
class BST:
root = None
def insert(self, k):
x = self.root
y = None
z = Node(k)
while x is not None:
y = x
if z.key < y.key:
x = x.left
elif y.key < z.key:
x =... |
s681834371 | p02283 | u805716376 | 1551268608 | Python | Python3 | py | Runtime Error | 0 | 0 | 789 | import copy
def selection_sort(A,n):
for i in range(n):
minj = i
for j in range(i,n):
if A[j] < A[minj]:
minj = j
A[i],A[minj] = A[minj], A[i]
return A
n = int(input())
r = [0]*n
for i in range(n):
r[i] = input().split()
for i in range(n):
if r[i][0... |
s664363594 | p02283 | u805716376 | 1551281201 | Python | Python3 | py | Runtime Error | 0 | 0 | 827 | import copy
def selection_sort(A,n):
for i in range(n):
minj = i
for j in range(i,n):
if A[j] < A[minj]:
minj = j
A[i],A[minj] = A[minj], A[i]
return A
n = int(input())
r = [0]*n
for i in range(n):
r[i] = input().split()
for i in range(n):
if r[i][0... |
s072390015 | p02283 | u799595944 | 1556582846 | Python | Python3 | py | Runtime Error | 0 | 0 | 1982 | class Node():
def __init__(self,id,value):
self.id = id
self.child = [None,None]
self.parent = -1
self.value = value
def addChild(self,child):
self.child = child
def setParent(self,parent):
self.parent = parent
nodes = {}
def movePreorder(nodes,order,start... |
s359816870 | p02283 | u799595944 | 1556582884 | Python | Python3 | py | Runtime Error | 0 | 0 | 1982 | class Node():
def __init__(self,id,value):
self.id = id
self.child = [None,None]
self.parent = -1
self.value = value
def addChild(self,child):
self.child = child
def setParent(self,parent):
self.parent = parent
nodes = {}
def movePreorder(nodes,order,start... |
s563939583 | p02283 | u799595944 | 1556583039 | Python | Python3 | py | Runtime Error | 0 | 0 | 1976 | class Node():
def __init__(self,id,value):
self.id = id
self.child = [None,None]
self.parent = -1
self.value = value
def addChild(self,child):
self.child = child
def setParent(self,parent):
self.parent = parent
nodes = {}
def movePreorder(nodes,order,start... |
s386802803 | p02283 | u799595944 | 1556583102 | Python | Python3 | py | Runtime Error | 0 | 0 | 1976 | class Node():
def __init__(self,id,value):
self.id = id
self.child = [None,None]
self.parent = -1
self.value = value
def addChild(self,child):
self.child = child
def setParent(self,parent):
self.parent = parent
nodes = {}
def movePreorder(nodes,order,start... |
s812904803 | p02283 | u805716376 | 1556850686 | Python | Python3 | py | Runtime Error | 0 | 0 | 750 | class Node():
def __init__(self, key):
self.key = key
self.left = self.right = None
def insert(key):
global root
x = root
y = None
while x:x, y = x.left if key < x.key else x.right , x
if y == None:root = Node(key)
elif y.key < key:y.right = Node(key)
else:y.lef... |
s620438108 | p02283 | u799595944 | 1558995089 | Python | Python3 | py | Runtime Error | 0 | 0 | 1976 | class Node():
def __init__(self,id,value):
self.id = id
self.child = [None,None]
self.parent = -1
self.value = value
def addChild(self,child):
self.child = child
def setParent(self,parent):
self.parent = parent
nodes = {}
def movePreorder(nodes,order,start... |
s807323550 | p02283 | u284474275 | 1424399495 | Python | Python | py | Runtime Error | 0 | 0 | 1221 | import sys
class TreeNode:
def __init__(self, val):
self.val = val
self.left = self.right = None
class BST:
def __init__(self):
self.root = None
def insert(self, node):
def helper(root):
if root is None:
root = node
elif node.val... |
s029665875 | p02283 | u024599888 | 1433055076 | Python | Python | py | Runtime Error | 0 | 0 | 1366 | import sys
class Node:
def __init__(self, key):
self.key = key
self.right = None
self.left = None
def insert(T, z): #z is node which you would like to insert
#initialization
y = ... |
s377854157 | p02283 | u024599888 | 1433055937 | Python | Python3 | py | Runtime Error | 0 | 0 | 1437 | import sys
#run by python3
class Node:
def __init__(self, key):
self.key = key
self.right = None
self.left = None
def insert(T, z): #z is node which you would like to insert
#initializati... |
s198270470 | p02283 | u024599888 | 1433056224 | Python | Python3 | py | Runtime Error | 0 | 0 | 1138 | import sys
class Node:
def __init__(self, key):
self.key = key
self.right = None
self.left = None
def insert(T, z):
y = None
x = T
... |
s772735416 | p02283 | u024599888 | 1433056388 | Python | Python3 | py | Runtime Error | 0 | 0 | 391 |
def preorder_walk(node):
print ('', node.key,end='')
if node.left:
preorder_walk(node.left)
if node.right:
preorder_walk(node.right)
T = None
num = int(sys.stdin.readline())
for _ in range(num):
cmd = sys.stdin.readline()
if(cmd.startswith('i')):
n = Node(int(cmd[7:]))
T = insert(T, n... |
s560710215 | p02283 | u024599888 | 1433056399 | Python | Python | py | Runtime Error | 0 | 0 | 391 |
def preorder_walk(node):
print ('', node.key,end='')
if node.left:
preorder_walk(node.left)
if node.right:
preorder_walk(node.right)
T = None
num = int(sys.stdin.readline())
for _ in range(num):
cmd = sys.stdin.readline()
if(cmd.startswith('i')):
n = Node(int(cmd[7:]))
T = insert(T, n... |
s604133085 | p02283 | u024599888 | 1433056831 | Python | Python | py | Runtime Error | 0 | 0 | 1606 | #!/usr/bin/env python3
import sys
#run by python3
class Node:
def __init__(self, key):
self.key = key
self.right = None
self.left = None
def ins... |
s078880866 | p02283 | u024599888 | 1433056890 | Python | Python3 | py | Runtime Error | 0 | 0 | 1682 | #!/usr/bin/env python3
import sys
#run by python3
class Node:
def __init__(self, key):
self.key = key
self.right = None
self.left = None
def ins... |
s950798353 | p02283 | u024599888 | 1433057080 | Python | Python3 | py | Runtime Error | 0 | 0 | 654 | def inorder_walk(node):
if node.left:
inorder_walk(node.left)
print ('', node.key, end='')
if node.right:
inorder_walk(node.right)
def preorder_walk(node):
print ('', node.key,end='')
if node.left:
preorder_walk(node.left)
if node.right:
preorder_walk(node.right)
if __name__... |
s549836942 | p02283 | u024599888 | 1433057142 | Python | Python3 | py | Runtime Error | 0 | 0 | 1743 | File Edit Options Buffers Tools Python Help
#!/usr/bin/env python3
#run by python3
class Node:
def __init__(self, key):
... |
s186825785 | p02283 | u024599888 | 1433057157 | Python | Python3 | py | Runtime Error | 0 | 0 | 1651 | #!/usr/bin/env python3
#run by python3
class Node:
def __init__(self, key):
self.key = key
self.right = None
self.left = None
def insert(T, z): #... |
s057807890 | p02283 | u024599888 | 1433057205 | Python | Python3 | py | Runtime Error | 0 | 0 | 1497 | #!/usr/bin/env python3
class Node:
def __init__(self, key):
self.key = key
self.right = None
self.left = None
def insert(T, z):
#initialization ... |
s644916446 | p02283 | u567281053 | 1460795103 | Python | Python | py | Runtime Error | 0 | 0 | 1387 | import sys
class binarySearchTree:
def __init__(self):
self.root = None
def insert(self, key):
z = Node(key)
y = None
x = self.root
while x:
y = x
if z.key < x.key:
x = x.left
else:
x = x.right
... |
s312998993 | p02283 | u567281053 | 1460796549 | Python | Python | py | Runtime Error | 0 | 0 | 1227 | import sys
class binarySearchTree:
def __init__(self):
self.root = None
def insert(self, key):
z = Node(key)
y = None
x = self.root
while x:
y = x
if z.key < x.key:
x = x.left
else:
x = x.right
... |
s127188054 | p02283 | u567281053 | 1460817958 | Python | Python | py | Runtime Error | 0 | 0 | 1035 | import sys
import time
class Node:
def __init__(self, key = None):
self.key = key
self.left = None
self.right = None
def insert(key):
global root
z = Node(key)
y = None
x = root
while x:
y = x
if z.key < x.key:
x = x.left
else:
... |
s103629490 | p02283 | u567281053 | 1460818919 | Python | Python | py | Runtime Error | 0 | 0 | 1202 | import sys
import time
class Node:
def __init__(self, key):
self.key = key
self.parent = None
self.left = None
self.right = None
def insert(key, z):
global root
y = None
x = root
while x:
y = x
if z.key < x.key:
x = x.left
else:
... |
s202071722 | p02283 | u742013327 | 1480313827 | Python | Python3 | py | Runtime Error | 40 | 7744 | 1382 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_8_A
#????????????
def insert(root, insert_node):
focus_node = root
parent = None
while not focus_node == None:
parent = focus_node
if focus_node["data"] > insert_node["data"]:
focus_node = focus_node["left"]
... |
s005104551 | p02283 | u112247126 | 1487673571 | Python | Python3 | py | Runtime Error | 0 | 0 | 1381 | import sys
class Node():
def __init__(self, key):
self.key = key
self.left = None
self.right = None
self.parent = None
def prewalk(self):
nodeList = [self.key]
if self.left:
nodeList += self.left.prewalk()
if self.right:
nodeList ... |
s573461463 | p02283 | u462831976 | 1489795829 | Python | Python3 | py | Runtime Error | 0 | 0 | 4760 | # -*- coding: utf-8 -*-
import random
class Tree:
def __init__(self):
self.root = None
def __str__(self):
if self.root == None:
return None
else:
return "TODO"
def print_inorder(self):
self.__inorder(self.root)
def __inorder(self, node):
... |
s168537355 | p02283 | u462831976 | 1489804226 | Python | Python3 | py | Runtime Error | 40 | 11672 | 5113 | # -*- coding: utf-8 -*-
import random
import sys
import os
class Tree:
def __init__(self):
self.root = None
def __str__(self):
if self.root == None:
return None
else:
return "TODO"
def print_inorder(self):
self.inorder_list = []
self.__ino... |
s870356863 | p02283 | u426534722 | 1491180791 | Python | Python3 | py | Runtime Error | 30 | 7740 | 800 | class Node():
key = 0
l = None
r = None
def __init__(self, key):
self.key = key
T = [] * int(5e6)
def insert(z):
if z == 0: return
y = None
x = 0
while x is not None:
y = x
x = (T[x].l if T[z].key < T[x].key else T[x].r)
if T[z].key < T[y].key: T[y].l = z
... |
s416566935 | p02283 | u603049633 | 1496322087 | Python | Python3 | py | Runtime Error | 0 | 0 | 1160 | # Binary Search Tree1
class BinaryTree():
def __init__(self):
self.key = None
self.parent = None
self.left = None
self.right = None
def insert(z):
global root
y = None
x = root
while(x != None):
y = x
if z.key < x.key:
x = x.left
e... |
s336896183 | p02283 | u603049633 | 1496322126 | Python | Python3 | py | Runtime Error | 0 | 0 | 1160 | # Binary Search Tree1
class BinaryTree():
def __init__(self):
self.key = None
self.parent = None
self.left = None
self.right = None
def insert(z):
global root
y = None
x = root
while(x != None):
y = x
if z.key < x.key:
x = x.left
e... |
s642485871 | p02283 | u603049633 | 1496323089 | Python | Python3 | py | Runtime Error | 0 | 0 | 1086 | class BinaryTree():
def __init__(self):
self.key = None
self.parent = None
self.left = None
self.right = None
def insert(z):
global root
y = None
x = root
while(x != None):
y = x
if z.key < x.key:
x = x.left
else:
x = x... |
s653538229 | p02283 | u603049633 | 1496323202 | Python | Python3 | py | Runtime Error | 0 | 0 | 1085 | class BinaryTree():
def __init__(self):
self.key = None
self.parent = None
self.left = None
self.right = None
def insert(z):
global root
y = None
x = root
while x != None:
y = x
if z.key < x.key:
x = x.left
else:
x = x.... |
s088783784 | p02283 | u491916705 | 1502512102 | Python | Python | py | Runtime Error | 0 | 0 | 2157 | class Node():
def __init__(self, id, left=-1, right=-1, parent=-1):
self.id = id
self.left = left
self.right = right
self.parent = parent
def show(self):
print 'node %d: parent = %d, left = %d, right = %d' % (self.id, self.parent, self.left, self.right)
class Stack():
... |
s305386069 | p02283 | u939814144 | 1503158543 | Python | Python3 | py | Runtime Error | 0 | 0 | 1833 | class Node():
def __init__(self, key):
self.key = key
self.left = None
self.right = None
self.parent = None
class BinarySearchTree():
def __init__(self):
self.root = None
def insert(self, key):
root_node = self.root
insert_node = Node(key)
p... |
s443580935 | p02283 | u798803522 | 1512402695 | Python | Python3 | py | Runtime Error | 0 | 0 | 1855 | with open("test.txt", "r") as f:
class BinarySearchTree:
def __init__(self):
self.root = None
def insert(self, x):
node = self.Node(x)
if self.root is None:
self.root = node
else:
here = self.root
#
... |
s502099647 | p02283 | u798803522 | 1512402722 | Python | Python3 | py | Runtime Error | 0 | 0 | 1602 | class BinarySearchTree:
def __init__(self):
self.root = None
def insert(self, x):
node = self.Node(x)
if self.root is None:
self.root = node
else:
here = self.root
#
temp = None
while here is not None:
t... |
s911339157 | p02283 | u150984829 | 1519492343 | Python | Python3 | py | Runtime Error | 0 | 0 | 1124 | import sys
class Node:
__slots__ = ['key', 'left', 'right']
def __init__(self, key):
self.key = key
self.left = None
self.right = None
class BST:
def __init__(self):
self.root = None
def insert(self, key):
x = self.root
y = None
z = Node(key)
... |
s532432716 | p02283 | u150984829 | 1519493578 | Python | Python3 | py | Runtime Error | 0 | 0 | 911 | import sys
class Node:
__slots__ = ['key', 'left', 'right']
def __init__(self, key):
self.key = key
self.left = self.right = None
class BST:
def __init__(self):
self.root = None
def insert(self, key):
x, y = self.root, None
while x != None: x, y = x.left if key ... |
s208113231 | p02283 | u150984829 | 1519493621 | Python | Python3 | py | Runtime Error | 0 | 0 | 911 | import sys
class Node:
__slots__ = ['key', 'left', 'right']
def __init__(self, key):
self.key = key
self.left = self.right = None
class BST:
def __init__(self):
self.root = None
def insert(self, key):
x, y = self.root, None
while x != None: x, y = x.left if key ... |
s967276402 | p02283 | u724548524 | 1525403009 | Python | Python3 | py | Runtime Error | 0 | 0 | 828 | import sys
class Node():
__slots__ = ['key', 'left', 'right']
def __init__(self, key):
self.key = key
self.left, self.right = None
root = None
def insert(z):
global root
x, y = root, None
while x:
y = x
if z < x.key:
x = x.left
else:
... |
s205629382 | p02283 | u724548524 | 1525403028 | Python | Python3 | py | Runtime Error | 0 | 0 | 822 | import sys
class Node():
__slots__ = ['key', 'left', 'right']
def __init__(self, key):
self.key = key
self.left, self.right = None
root = None
def insert(z):
global root
x, y = root, None
while x:
y = x
if z < x.key:
x = x.left
else:
... |
s695690316 | p02283 | u724548524 | 1525403037 | Python | Python3 | py | Runtime Error | 0 | 0 | 821 | import sys
class Node():
__slots__ = ['key', 'left', 'right']
def __init__(self, key):
self.key = key
self.left, self.right = None
root = None
def insert(z):
global root
x, y = root, None
while x:
y = x
if z < x.key:
x = x.left
else:
... |
s704164289 | p02283 | u724548524 | 1525403067 | Python | Python3 | py | Runtime Error | 0 | 0 | 822 | import sys
class Node():
__slots__ = ['key', 'left', 'right']
def __init__(self, key):
self.key = key
self.left, self.right = None
root = None
def insert(z):
global root
x, y = root, None
while x:
y = x
if z < x.key:
x = x.left
else:
... |
s344393163 | p02283 | u126478680 | 1526904012 | Python | Python3 | py | Runtime Error | 0 | 0 | 2268 | from collections import deque
from enum import Enum, auto
class BinaryTreeNode():
__slots__ = ['left', 'right', 'val']
def __init__(self, left=None, right=None, val=None):
self.left = left
self.right = right
self.val = val
class BinarySearchTree():
def __init__(self):
self.... |
s561799819 | p02283 | u126478680 | 1526904508 | Python | Python3 | py | Runtime Error | 30 | 6344 | 2292 | from collections import deque
from enum import Enum, auto
class BinaryTreeNode():
__slots__ = ['left', 'right', 'val']
def __init__(self, left=None, right=None, val=None):
self.left = left
self.right = right
self.val = val
class BinarySearchTree():
def __init__(self):
self.... |
s261151222 | p02283 | u404682284 | 1528281866 | Python | Python3 | py | Runtime Error | 0 | 0 | 2824 | class NullNode():
def __init__(self):
self.id = None
class Node():
def __init__(self, id):
self.id = id
self.parent = NullNode()
self.left = NullNode()
self.right = NullNode()
def preorder(node, out_list=[]):
if node.id is not None:
out_list.append(str(node.... |
s233038328 | p02283 | u318430977 | 1528995477 | Python | Python3 | py | Runtime Error | 0 | 0 | 687 | def reconstruct(pre_list, in_list):
if len(pre_list) <= 1:
return pre_list
now = pre_list[0]
split_place = in_list.index(now)
pre_left = pre_list[1:split_place + 1]
in_left = in_list[0:split_place]
pre_right = pre_list[split_place + 1:]
in_right = in_list[split_place + 1:]
return... |
s229440462 | p02284 | u798803522 | 1540187834 | Python | Python3 | py | Runtime Error | 0 | 0 | 2430 | from io import StringIO
class BinaryTree:
class Node:
def __init__(self, key):
self.key = key
self.left = None
self.right = None
self.parent = None
def __init__(self):
self.root = None
self.output = StringIO()
def insert(self, key)... |
s203806655 | p02284 | u798803522 | 1540187915 | Python | Python3 | py | Runtime Error | 0 | 0 | 2423 | from io import StringIO
class BinaryTree:
class Node:
def __init__(self, key):
self.key = key
self.left = None
self.right = None
self.parent = None
def __init__(self):
self.root = None
self.output = StringIO()
def insert(self, key)... |
s703531704 | p02284 | u798803522 | 1540188008 | Python | Python3 | py | Runtime Error | 0 | 0 | 2423 | from io import StringIO
class BinaryTree:
class Node:
def __init__(self, key):
self.key = key
self.left = None
self.right = None
self.parent = None
def __init__(self):
self.root = None
self.output = StringIO()
def insert(self, key)... |
s215648082 | p02284 | u130979865 | 1460172044 | Python | Python | py | Runtime Error | 0 | 0 | 1361 | # -*- coding: utf-8 -*-
class Node_Class():
def __init__(self, key, parent, left, right):
self.key = key
self.parent = parent
self.left = left
self.right = right
def insert(z):
global root
y = None
x = root
while x != None:
y = x
if z.key < x.key:
... |
s574410279 | p02284 | u684241248 | 1528193020 | Python | Python3 | py | Runtime Error | 0 | 0 | 2004 | class Tree:
def __init__(self, orders):
self.root = None
for order in orders:
if len(order) == 1:
self.inorder_print()
self.preorder_print()
else:
if len(order[0]) == 4:
self.find(int(order[1]))
... |
s708922663 | p02284 | u912237403 | 1373888572 | Python | Python | py | Runtime Error | 0 | 0 | 1151 | import sys
tree={}
np = -1
home=0
tree[home]=[None, None, None]
def search(p, x):
while p != None:
tmp = tree[p]
if tmp[0] == x: return True
if x < tmp[0]:
p = tmp[1]
else:
p = tmp[2]
return False
def node(x):
global np
np += 1
tree[np] = [... |
s803992963 | p02285 | u597769560 | 1551539244 | Python | Python3 | py | Runtime Error | 20 | 5648 | 2368 | # -*- coding: utf-8 -*-
"""
Created on Sat Mar 2 17:11:49 2019
@author: Yamazaki Kenichi
"""
m = int(input())
A = [list(input().split()) for i in range(m)]
T = [[-1,-1,-1,-1]]
def insert(T,u,x):
if T[0][3] == -1:
T[0][3] = x
return
if x < T[u][3]:
if T[u][1] == -1:
T[u][1... |
s830438275 | p02285 | u357267874 | 1556281307 | Python | Python3 | py | Runtime Error | 20 | 5620 | 4456 | class Node:
def __init__(self, key):
self.key = key
self.parent = None
self.left = None
self.right = None
class Tree:
def __init__(self):
self.root = None
self.inorder = []
self.preorder = []
def insert(self, node):
p = None
x = self.... |
s224309963 | p02285 | u357267874 | 1556328066 | Python | Python3 | py | Runtime Error | 20 | 5624 | 4409 | class Node:
def __init__(self, key):
self.key = key
self.parent = None
self.left = None
self.right = None
class Tree:
def __init__(self):
self.root = None
self.inorder = []
self.preorder = []
def insert(self, node):
p = None
x = self.... |
s847618281 | p02285 | u357267874 | 1556336570 | Python | Python3 | py | Runtime Error | 30 | 5624 | 5022 | class Node:
def __init__(self, key):
self.key = key
self.parent = None
self.left = None
self.right = None
class Tree:
def __init__(self):
self.root = None
self.inorder = []
self.preorder = []
def insert(self, node):
p = None
x = self.... |
s127995951 | p02285 | u567380442 | 1421931241 | Python | Python3 | py | Runtime Error | 30 | 6828 | 2327 | import sys
class Tree():
def __init__(self):
self.root = None
def insert(self, key):
z = Node(key)
y = None
x = self.root
while x:
y = x
if z.key < x.key:
x = x.left
else:
x = x.right
z.parent = y... |
s713087730 | p02285 | u882992966 | 1442416090 | Python | Python3 | py | Runtime Error | 20 | 7804 | 5041 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_8_A&lang=jp
# cat alds1_8_c.txt | ./alds1_8_c.py
import sys
class Node(object):
def __init__(self, key=None, parent=None):
self.key = key
self.parent = parent
self.left = None
... |
s111020150 | p02285 | u669284080 | 1446889127 | Python | Python | py | Runtime Error | 10 | 6620 | 2403 | from __future__ import print_function
from sys import stdin
class Node:
def __init__(self, id):
self.id = id
self.left = None
self.right = None
self.parent = None
def preorder_tree_walk(root):
print('', root.id, end='')
if root.left != None:
preorder_tree_walk(root.l... |
s136709154 | p02285 | u881590806 | 1449657318 | Python | Python | py | Runtime Error | 10 | 6372 | 2406 | def insert(tree,k):
y = None
x = tree
z = {'key':k, 'parent':None, 'left':None, 'right':None}
while x != None:
y = x
if x['key'] > k:
x = x['left']
else:
x = x['right']
z['parent'] = y
if y == None:
tree = z
elif y['key'] > k:
y... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.