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 |
查不出错,请大牛指教(内附代码)不知道为什么WA,给组测试用例也行 #include <stdio.h> struct ZB { int start; int end; int R; int jd; }; struct ZB S[60]; void qingkong() { int i; for(i=0;i<60;i++) { S[i].start=0; S[i].end=0; S[i].R=0; } } main() { int i,j,n,r1,l1,a,JD,r,b[60],t; while(1) { scanf("%d",&n); if(n==0) break; qingkong(); r1=0; l1=0; for(i=0;i<n;i++) { t=0; scanf("%d",&r); if(i==0) { r1=r; S[0].start=0; S[0].end=2*r; S[0].R=r; S[0].jd=r; l1=2*r; JD=r; } else{ a=r-r1; if(a>0){ JD=JD+2*r1; S[i].start=JD-r; S[i].end=JD+r; S[i].jd=JD; l1=S[i].end; S[i].R=r; r1=r; } if(a<0){ if(r>S[i-1].R) { S[i].start=JD+r; S[i].end=JD+3*r; S[i].R=r; if(S[i].end>l1) { l1=S[i].end; JD=JD+2*r; r1=r; S[i].jd=JD+2*r; } else S[i].jd=S[i-1].jd+2*S[i-1].R; } else{ S[i].start=S[i-1].jd+r; S[i].end=S[i-1].jd+3*r; S[i].R=r; S[i].jd=S[i-1].jd+2*r; if(S[i].end>l1) { l1=S[i].end; JD=JD+2*r; r1=r; } } } if(a==0){ S[i].start=JD+r; S[i].end=JD+3*r; S[i].R=r; l1=S[i].end; JD=JD+2*r; } } } for(i=0;i<n;i++) { for(j=0;j<n;j++) if(S[i].R<S[j].R) { if(S[i].start<=S[j].start&&S[i].end<=S[j].end&&S[j].start<=S[i].end) S[i].end=S[j].start; if(S[i].start>=S[j].start&&S[i].end>=S[j].end&&S[i].start<=S[j].end) S[i].start=S[j].end; if(S[i].start>=S[j].start&&S[i].end<=S[j].end) { S[i].start=-1; S[i].end=0;} } if(S[i].start!=-1&&S[i].end!=0) {b[t]=i;t++;} } for(i=0;i<t-1;i++) printf("%d ",b[i]+1); printf("%d\n",b[i]+1); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator