| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:1089题材,不知死在哪了,求指教In Reply To:1089题材,不知死在哪了,求指教 Posted by:200914 at 2013-03-17 14:15:04 > #include<iostream> > using namespace std; > #define N 100000 > void sort(int array[],int end[],int zz,int yy) > { > > int k,i,z,y,k1; > if(zz<yy) > { > z=zz;y=yy;k=array[z];k1=end[z]; > do{ > while((z<y)&&(array[y]>=k)) > y--; > if(z<y) > { > array[z]=array[y]; > end[z]=end[y]; > z++; > } > while((z<y)&&(array[z]<=k)) > { > > z++; > } > if(z<y) > { > array[y]=array[z]; > end[y]=end[z]; > } > > }while(z!=y); > array[z]=k;end[z]=k1; > sort(array,end,zz,z-1); > sort(array,end,z+1,yy); > } > > } > > int main() > { > int n,i=0,t=0,u=0; > int begin[N],end[N]; > cin>>n; > for(i=0;i<n;i++) > { > cin>>begin[i]>>end[i]; > } > sort(begin,end,0,n-1); > > for(i=0;i<n-1;i++) > { > for(int j=0;j<n-1-i;j++) > { > if((begin[j]==begin[j+1])&&(end[j]>end[j+1])) > { > u=end[i]; > end[j]=end[j+1]; > end[j+1]=u; > } > } > } > u=begin[0],t=end[0]; > for(i=0;i<n;i++) > { > if(end[i]<begin[i+1]) > { > cout<<u<<" "<<t<<endl; > u=begin[i+1]; > t=end[i+1]; > } > > > else if(end[i]<=end[i+1]) > { > t=end[i+1]; > } > else{ > > while((i<n)&&(t>end[i+1])) > { > i++; > > if(t<begin[i+1]) > { > cout<<u<<" "<<t<<endl; > u=begin[i+1]; > t=end[i+1]; > break; > } > else if(t<=end[i+1]) > { > t=end[i+1]; > } > } > } > } > cout<<u<<" "<<t<<endl; > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator