human
Total number of cells covered in a matrix after D days | Function to return the total infected cells after d days.
Top extension.
Bottom extension.
Left extension.
Right extension.
Calculating the cells in each quadrilateral.
Sum all of them to get total cells in each quadrilateral.
Add the singleblocks along the lines of top , down , left , right.
Return the ans.
Driver Code.
Dimensions of cell.
Starting Coordinates.
Number of Days.
Function Call"
Solution in Python:
 Give me a code to total number of cells covered in a matrix after D days and the other steps required?
assistant
#Here is code to total number of cells covered in a matrix after D days and the other steps required.
 def solve ( n , m , x , y , d ) :
	top = min ( d , x - 1 )
	down = min ( d , n - x )
	left = min ( d , y - 1 )
	right = min ( d , m - y )
	quad1 = top * left
	quad2 = left * down
	quad3 = down * right
	quad4 = right * top
	totalsq = ( quad1 + quad2 + quad3 + quad4 )
	singleBlocks = ( top + down + left + right + 1 )
	return totalsq + singleBlocks
if __name__ == ' _ _ main _ _ ' :
	n = 10
	m = 10
	x = 7
	y = 8
	d = 4
	d -= 1
	print ( solve ( n , m , x , y , d ) )