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 |
大家看看为什么阿,第一个case就tle崩溃阿~~~~大家看看那里问题阿 !!多谢多谢Problem Id:1009 User Id:first Memory:-488K Time:0MS ~~~~~~~~~~~~~~~~~~ Language:C++ Result:Time Limit Exceed Source #include <iostream> #include <vector> using namespace std; void main() { short gray,dist,tempd; long int N,num,i,j; vector <short> graydata; graydata.push_back(0); vector <long>min; min.push_back(0); vector<long>max; max.push_back(0); scanf("%ld\n",&N); while(N!=0) { scanf("%d %ld",&gray,&num); while(gray!=0||num!=0) { graydata.push_back(gray); min.push_back(max.back()+1); max.push_back(min.back()+num-1); scanf("%d %ld",&gray,&num); } printf("%ld\n",N); int k; num=0;dist=0;tempd=-1; for(i=1;i<graydata.size();i++) { for(j=min[i];j<=max[i];j++) { if(j-N-1>=min[i]&&j+N+1<=max[i]) if(tempd!=0) { cout<<tempd<<num<<endl; num=max[i]-min[i]-2*N-1; tempd=0; j=max[i]-N-1; } else { num+=max[i]-min[i]-2*N-1; j=max[i]-N-1; } else { if(j%N!=1) { k=i; while(k>=1&&j-N-1<min[k]) k--; if(k>=1) dist=(dist<abs(graydata[i]-graydata[k]))?abs(graydata[i]-graydata[k]):dist; k=i; while(k>=1&&j-1<min[k]) k--; if(k>=1) dist=(dist<abs(graydata[i]-graydata[k]))?abs(graydata[i]-graydata[k]):dist; k=i; while(k<graydata.size()&&j+N-1>max[k]) k++; if(k<graydata.size()) dist=(dist<abs(graydata[i]-graydata[k]))?abs(graydata[i]-graydata[k]):dist; } k=i; while(k>=0&&j-N<min[k]) k--; if(k>=1) dist=(dist<abs(graydata[i]-graydata[k]))?abs(graydata[i]-graydata[k]):dist; k=i; while(k<graydata.size()&&j+N>max[k]) k++; if(k<graydata.size()) dist=(dist<abs(graydata[i]-graydata[k]))?abs(graydata[i]-graydata[k]):dist; if(j%N!=0) { k=i; while(k>=1&&j-N+1<min[k]) k--; if(k>=1) dist=(dist<abs(graydata[i]-graydata[k]))?abs(graydata[i]-graydata[k]):dist; k=i; while(k<graydata.size()&&j+1>max[k]) k++; if(k<graydata.size()) dist=(dist<abs(graydata[i]-graydata[k]))?abs(graydata[i]-graydata[k]):dist; k=i; while(k<graydata.size()&&j+N+1>max[k]) k++; if(k<graydata.size()) dist=(dist<abs(graydata[i]-graydata[k]))?abs(graydata[i]-graydata[k]):dist; } if(tempd==-1) { tempd=dist;num=1;dist=0;} else if(dist!=tempd) { printf("%d %ld\n",tempd,num); num=1;tempd=dist;dist=0;} else {num++;dist=0;} } } } printf("%d %ld\n",tempd,num); printf("%d %ld\n",0,0); graydata.resize(1); min.resize(1); max.resize(1); scanf("%d",&N); } printf("%d",0); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator