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:W A好几次了 也不知什么问题 哪位 大虾有兴趣帮我看看吧!In Reply To:我想问一下大家!!! Posted by:810974380 at 2009-07-24 14:51:55 > 开始是:#include<iostream> using namespace std; int main() { int num,n,t,t1,t2,result,path,a[410][2],b[400]; cin>>num; while(num--) { cin>>n; result=0;path=0; for(int i=0;i<n;i++) { cin>>a[i][0]>>a[i][1];b[i]=0; if(a[i][0]>a[i][1]) {t=a[i][0];a[i][0]=a[i][1];a[i][1]=t;} } for(int j=0;j<n;j++) for(int k=j+1;k<n;k++) if(a[j][0]>a[k][0]) { t1=a[j][0];t2=a[j][1]; a[j][0]=a[k][0];a[j][1]=a[k][1]; a[k][0]=t1;a[k][1]=t2; } for(int l=0;l<n;l++) { for(int m=l+1;m<n;m++) if(a[l][1]>=a[m][0]) { if((a[l][1]<=a[m][1])||((a[l][1]>=a[m][1])&&(a[l][0]<=a[m][1]))&&b[path]==0) {result++;b[path]++;} } path++; } if(result!=0) cout<<result*10+10<<endl; else cout<<"10"<<endl; } return 0; } 后来改成: #include<iostream> #include<algorithm> using namespace std; int main() { int num,n,t,t1,t2,a[410][2],b[400]; cin>>num; while(num--) { cin>>n; for(int i=0;i<n;i++) { cin>>a[i][0]>>a[i][1];b[i]=0; if(a[i][0]>a[i][1]) {t=a[i][0];a[i][0]=a[i][1];a[i][1]=t;} } for(int j=0;j<n;j++) for(int k=j+1;k<n;k++) if(a[j][0]>a[k][0]) { t1=a[j][0];t2=a[j][1]; a[j][0]=a[k][0];a[j][1]=a[k][1]; a[k][0]=t1;a[k][1]=t2; } for(int l=0;l<n;l++) { for(int m=0;m<n;m++) if(a[l][1]>=a[m][0]) { if((a[l][1]<=a[m][1])||((a[l][1]>=a[m][1])&&(a[l][0]<=a[m][1]))) {b[l]++;} } } sort(&b[0],&b[n]); if(b[0]!=0) cout<<b[0]*10<<endl; else cout<<"10"<<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