12345678910111213141516171819 |
- def recurse(tree, id, min, max):
- if id >= len(tree):
- return True
- if tree[id] <= min or max <= tree[id]:
- return False
- return recurse(tree, id*2, min, tree[id]) and recurse(tree, id*2+1, tree[id], max)
- if __name__ == '__main__':
- line = input().strip().split(',')
- tree = [0]
- for l in line:
- if l == 'None':
- continue
- tree.append(int(l))
- if recurse(tree, 1, (1 << 32) * -1, 1 << 32 - 1):
- print('True')
- else:
- print('False')
|