uva 105 solution

#include<cstdio>

#include<vector>

using namespace std;

int L[6000], H[6000], R[6000];

int skyline[500000];

vector<int > out;

int main() {

int max_R = 0;

for (int i = 0;; i++) {

if( scanf (“%d %d %d” , &

for ( int j = L[i]; j <

if(H[i] > skyline[

skyline[j] = H

}

if(R[i] > max_R)

max_R = R[i];

}

int curr = 0;

for (int i = 0; i < max_R +

if(skyline[i] != curr)

out.push_back(i);

out.push_back(skyli

curr = skyline[i];

}

}

printf( “%d” , out[0]);

for (int i = 1; i < out.siz

printf( ” %d” , out[i]);

printf( “\n” );

}

input

1

2

3

4

5

6

7

8

1 11 5

2 6 7

3 13 9

12 7 16

14 3 25

19 18 22

23 13 29

24 4 28

output

1 1 11 3 13 9 0 12 7 16 3 19 18 2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s