You are viewing a single comment's thread. Return to all comments →
def surfaceArea(A): s=H*W*2 for i in range(H): for j in range(W): if j==0: s+=A[i][j] s+=abs(A[i][j]-A[i][j+1]) A.append([0]*W) for i in range(W): for j in range(H): if j==0: s+=A[j][i] s+=abs(A[j][i]-A[j+1][i]) return s if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') first_multiple_input = input().rstrip().split() H = int(first_multiple_input[0]) W = int(first_multiple_input[1]) A = [] for _ in range(H): A.append(list(map(int, input().rstrip().split()))+[0]) result = surfaceArea(A) fptr.write(str(result) + '\n') fptr.close()
Seems like cookies are disabled on this browser, please enable them to open this website
3D Surface Area
You are viewing a single comment's thread. Return to all comments →