#include <iostream> using namespace std; int main() { int L,H,R; int counter = 0; int temp_pre,temp_curr; int min = 20000,max = 0; int building[10001] = {0}; while(cin>>L>>H>>R) { if(min>L) min = L; if(max<R) max = R; for(int i = L ; i < R ; i++) { if(building[i] < H) building[i] = H; } counter++; } bool check = true; temp_pre = building[min]; cout<<min<<" "<<temp_pre<<" "; for(int j = min+1 ; j <= max ; j++) { temp_curr = building[j]; if(check) //check == true { if(temp_curr == 0) { check = false; cout<<j<<" "<<temp_curr; }else { if(temp_curr != temp_pre) { cout<<j<<" "<<temp_curr<<" "; temp_pre = temp_curr; } } } else { if(temp_curr == 0) { //do nothing }else { check = true; temp_pre = temp_curr; cout<<" "<<j<<" "<<temp_curr<<" "; } } } cout<<endl; return 0; }
Tuesday, July 31, 2012
ACM105 -- The Skyline Problem
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment