# Read topographic height matrix from a specified input stream. # # Returns a 5-tuple: # # nrows, ncols, heights, maxheight, minheight = read_heights(sys.stdin) # # Where: # nrows and ncols are what you think # heights[i][j] is a 2D matrix (list-of-lists) with height numbers # maxheight and minheight are what you think # # def read_heights(stream): nrows = int(stream.readline()) ncols = int(stream.readline()) heights = [ncols*[0] for i in xrange(nrows)] for j in xrange(ncols): for i in xrange(nrows): heights[i][j] = float(stream.readline()) maxheight = max(heights[0]) minheight = min(heights[0]) for heightrow in heights: maxheight = max(maxheight, max(heightrow)) minheight = min(minheight, min(heightrow)) print "rows=%d cols=%d maxheight=%d minheight=%d" % \ (nrows, ncols, maxheight, minheight) return (nrows, ncols, heights, maxheight, minheight)