TYVJ 1007 排座椅 by C++

   1: #include
   2: using namespace std;
   3: int m,n,k,l,d;
   4: const int maxn=3000;
   5: int hen[maxn]={0},shu[maxn]={0},posh[maxn]={0},poss[maxn]={0};
   6: bool opth[maxn]={0},opts[maxn]={0};
   7:  
   8: void get_prepare()
   9: {
  10:     int x1,y1,x2,y2;
  11:     cin >> n >> m >> k >> l >> d;
  12:     for (int i=0;i 
     
  13:         cin >> x1 >> y1 >> x2 >> y2;
  14:         x1==x2?shu[(y1+y2)/2-1]++:hen[(x1+x2)/2-1]++;
  15:     }
  16:     for (int i=0;i 
     
  17:     for (int i=0;i 
     
  18: }
  19: void sorth(int l,int r)
  20: {
  21:     int i=l,j=r,mid=hen[(l+r)/2],tmp;
  22:     while (i<=j){
  23:         while (hen[i]>mid) i++;
  24:         while (hen[j] 
     
  25:         if (i<=j){
  26:             tmp=hen[i];hen[i]=hen[j];hen[j]=tmp;
  27:             tmp=posh[i];posh[i++]=posh[j];posh[j--]=tmp;
  28:         }
  29:     }
  30:     if (i 
     
  31:     if (l 
     
  32: }
  33: void sorts(int l,int r)
  34: {
  35:     int i=l,j=r,mid=shu[(l+r)/2],tmp;
  36:     while (i<=j){
  37:         while (shu[i]>mid) i++;
  38:         while (shu[j] 
     
  39:         if (i<=j){
  40:             tmp=shu[i];shu[i]=shu[j];shu[j]=tmp;
  41:             tmp=poss[i];poss[i++]=poss[j];poss[j--]=tmp;
  42:         }
  43:     }
  44:     if (i 
     
  45:     if (l 
     
  46: }
  47: int main()
  48: {
  49:     get_prepare();
  50:     sorth(0,n-1);
  51:     sorts(0,m-1);
  52:     for (int i=0;i 
     
  53:     for (int i=0;iif (opth[i]) cout << i << ' ';
  54:     cout << '\n';
  55:     for (int i=0;i 
     
  56:     for (int i=0;iif (opts[i]) cout << i << ' ';
  57:     cout << '\n';
  58:     return 0;
  59: }
还不会用一个过程对两个不同的数组进行排序,所以……将就看吧

转载于:https://www.cnblogs.com/FreeDestiny/archive/2012/07/05/2577730.html

你可能感兴趣的:(TYVJ 1007 排座椅 by C++)