@NathanMerrill In B I wanted to read the N (the length of the matrix) with int N; cin >> N; but forgot the cin >> n part. Wondered for a few minutes why I didn't get any output.
In Figure 1, (a) is the input mesh, we want to find several rectangles to cover the red cells in (a), at the same time, the sum area of these rectangles should be as small as possible. Figure 1(b) and Figure 1(c) are two ways. Obviously, (c) is a better way due to the smaller sum of area the gr...