int main() { //std::vector<building> b = { {5,9,3}, {2,5,4}, {8, 10,9} }; std::vector<building> b = { { 1,4,2 },{ 2,3,2 } }; skyline(b); }
int main(void) { int i,j=0,a[32]; skyline(a,0,7); printf("(%d,%d) ",a[0],a[1]); for (i=3; i<32; i+=2) { if (a[i] != a[i-2]) { printf("(%d,%d) ",a[i-1],a[i]); } } return 0; }
void skyline(int a[], int low, int high) { int a1[32],a2[32],i1,i2,i3,i,n,h1,h2; if (high-low == 0) { for (i=0; i<4; i++) { a[i] = data[low][i]; } } else { skyline(a1,low,(low+high)/2); skyline(a2,(low+high)/2+1,high); i1=0; i2=0; i3=0; h1=0; h2=0; n=2*(high-low+1)-1; while(i1<=n || i2<=n) { if(i1<=n && (a1[i1]<a2[i2] || i2>=n)){ h1=a1[i1+1]; a[i3++]=a1[i1++]; if(h1>=h2) { a[i3++]=a1[i1++]; } else { a[i3++]=h2; i1++; } } else { if(i2<=n && (a2[i2]<=a1[i1] || i1>=n)) { h2=a2[i2+1]; a[i3++]=a2[i2++]; if(h2>=h1) { a[i3++]=a2[i2++]; } else { a[i3++]=h1; i2++; } } } } } }
vector<int> QFlow::Execute() { INI_PROFILER(); // sort: ComputeScores(); #if defined(_OPENMP) std::__parallel::sort( data_, data_ + n_, STupleComp ); #else std::sort( data_, data_ + n_, STupleComp ); #endif UPD_PROFILER("01 pq-filter"); const int num_survive = skyline(); for (uint32_t i = 0; i < num_survive; ++i) { skyline_.push_back( data_[i].pid ); } PRI_PROFILER(); return skyline_; }