// Va problem 105-Skyline problem // verdict: accepted // submission date: 2011-11-22/Ultraviolet Run Time: 0.036 S // All Rights Reserved (c) qiu, 2011. Metaphysis # Yeah dot net // [problem solving method] // initially, we wanted to obtain all the intersection points and then determine whether the intersection points are in the rectangle, but the written Code Ugly and ugly, I thought, isn't there any better method? Taking a closer look at the figure given by the question, do we not use arrays to simulate tall buildings? Anyway, the maximum coordinate is // 10000. A one-dimensional array is used to represent the abscissa. The array value is used to represent the ordinate, so the "Parallel" of the rectangle is quite easy to represent, you only need to // determine the maximum ordinate of a horizontal coordinate. You can use the idea similar to the filling method to create an array of "high-rise buildings". For a given rectangle (L, H, H, r), set all values in the range of [L, R] as H. Of course, the precondition is that the previous value of the array is less than // H, this is equivalent to achieving a higher building to overwrite a shorter building, thus conveniently representing the "union" of the rectangle ", then it is not difficult to input/output the coordinate value as required. # Include <iostream> # include <cstring> using namespace STD; # define maxn 10010int grid [maxn]; int main (INT argc, char const * argv []) {int left, height, right, leftmost, rightmost = 0; bool leftsetted = false; memset (grid, 0, sizeof (GRID); While (CIN> left> height> right) {for (INT I = left; I <= right; I ++) grid [I] = max (grid [I], height); If (! Leftsetted) {leftmost = left; leftsetted = true;} rightmost = max (rightmost, right) ;}cout <leftmost <"" <grid [leftmost]; int current = leftmost; For (INT I = leftmost; I <= rightmost; I ++) {If (grid [I] = grid [current]) continue; else {If (grid [I]> grid [current]) cout <"<I <" "<grid [I]; elsecout <"" <(I-1) <"" <grid [I]; current = I ;}} cout <"" <rightmost <"0 \ n"; return 0 ;}