poj 1116 library

写了一天,还是有一组数据过不了,我真的尽力了啊。。那组最后结果是(2, 34)的数据,我一直输出(1,34),伤心啊。。

#include 
#include 
using namespace std;

int h[105], ls[105], le[105], lp[105], rp[105];
int X1, Y1, X2, Y2, n, lb;

bool csupport(int i){
    return (Y1-h[i]>=Y2)&&(le[i]>=X2);
}

int shift_surpport(int tls2, int tle, int tlp, int trp){
    int tmpM = 10000;
    for(int i=tls2;i>=0&&i+tle>=tls2+X2;i--)
       if(i+tle<=X1){
           int center = 2*i + tle;
           if(center>=2*tlp&¢er<=2*trp)
               return 0;
            else if(!(i+tletrp)){
               tmpM = 1;
            }
                   
       }
    return tmpM;
}

int cut_right(int tlb, int tle, int trp){
    int tcut = 0;
    tcut += (tlb+tle>X1?tlb+tle-X1:0);
    tle -= tcut;
    tcut += (tle>2*(trp-tlb)?tle-2*(trp-tlb):0);
    return tcut;
}

int cut_left(int tlb, int tle, int tlp){
    int tcut = 0;
    tcut += (tle>tlb?tle-tlb:0);
    tle -= tcut;
    tcut += (tle>2*(tlb-tlp)?tle-2*(tlb-tlp):0);
    return tcut;
}

int main(){
    int lpp, rpp, min_mp = 10000, min_cs = 10000;
    scanf("%d%d%d%d", &X1, &Y1, &X2, &Y2);
    scanf("%d", &n);
    for(int i=0;i 1) continue;
                for(int j=0;j=X1-lb-X2?lb:X1-lb-X2);
                        if(h[j]=h[i]+Y2) continue;
                        else if(ls[j]+le[j]<=lb||ls[j]>=lb+X2) continue;
                        else if(lp[j]>lb&&rp[j]=lb+X2){
                            cs += cut_right(lb+X2, le[j], rp[j]);
                        }else if(rp[j]<=lb){
                            cs += cut_left(lb, le[j], lp[j]);
                        }else if(lp[j]<=lb&&rp[j]>=lb+X2){
                            mp++;
                            if(space==0) mp++;
                            cs += (le[j]>space?le[j] - space:0);
                        }else if(lp[j]>lb&&lp[j]X1-lb-X2?le[j]-X1+lb+X2:0);
                        }else if(rp[j]>lb&&rp[j]lb?le[j]-lb:0);
                        }else{
                            printf("*******************\n");
                        }
                    }
                }
                if(mp


你可能感兴趣的:(算法)