#include #include #include #include #include using namespace std; bool recurse(vector tree, int root, int min, int max); int main() { vector tree(1); string tmp; while (getline(cin, tmp, ',')) tree.push_back(stoi(tmp)); if (recurse(tree, 1, INT32_MIN, INT32_MAX)) printf("True\n"); else printf("False\n"); return 0; } bool recurse(vector tree, int root, int min, int max) { if (tree.size() <= root) return true; if (tree[root] <= min || max <= tree[root]) return false; return recurse(tree, root*2, min, tree[root]) && recurse(tree, root*2+1, tree[root], max); }