def search(lo, hi): if (hi - lo) == 1: return lo mid = (hi + lo) // 2 stdio.write('Greater than or equal to ' + str(mid) + '? ') if stdio.readBool(): return search(mid, hi) else: return search(lo, mid)
def search(lo, hi): if (hi - lo) == 1: return lo mid = (hi + lo) // 2 stdio.write("Greater than or equal to " + str(mid) + "? ") if stdio.readBool(): return search(mid, hi) else: return search(lo, mid)
def readBool1D(): """ Read from sys.stdin and return an array of booleans. An integer at the beginning of sys.stdin defines the array's length. """ count = stdio.readInt() a = create1D(count, None) for i in range(count): a[i] = stdio.readBool() return a
def readBoolean1D(): """ Read from sys.stdin and return an array of booleans. An integer at the beginning of sys.stdin defines the array's length. """ count = stdio.readInt() a = create1D(count, None) for i in range(count): a[i] = stdio.readBool() return a
def readBool2D(): """ Read from sys.stdin and return a two-dimensional array of booleans. Two integers at the beginning of sys.stdin define the array's dimensions. """ rowCount = stdio.readInt() colCount = stdio.readInt() a = create2D(rowCount, colCount, False) for row in range(rowCount): for col in range(colCount): a[row][col] = stdio.readBool() return a
def readBoolean2D(): """ Read from sys.stdin and return a two-dimensional array of booleans. Two integers at the beginning of sys.stdin define the array's dimensions. """ rowCount = stdio.readInt() colCount = stdio.readInt() a = create2D(rowCount, colCount, False) for row in range(rowCount): for col in range(colCount): a[row][col] = stdio.readBool() return a