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:为什么老是wrong 测试的所有数据都正确In Reply To:为什么老是wrong 测试的所有数据都正确 Posted by:huangcan at 2014-11-17 14:51:16 > #include <iostream> > #include <algorithm> > > using namespace std; > > struct room{ > int r1; > int r2; > bool flag; > }; > bool cmp(room a,room b) > { > return a.r1<b.r1; > } > > room r[201]; > int main() > { > int test,temp; > cin>>test; > while(test>0) > { > int N; > int ti=0; > cin>>N; > room re; > for(int i=0;i<N;i++) > { cin>>r[i].r1>>r[i].r2; > if(r[i].r1>r[i].r2) > { > temp=r[i].r1; > r[i].r1=r[i].r2; > r[i].r2=temp; > } > r[i].flag=false; > } > sort(r,r+N,cmp); > > for(int j=0;j<N;j++) > { > if(!r[j].flag) > { > ti=ti+10; > re.r1=(r[j].r1+1)/2;re.r2=(r[j].r2+1)/2; > for(int i=j+1;i<N;i++) > { > if((r[i].r1+1)/2>re.r2) > { > r[i].flag=true; > re.r1=(r[i].r1+1)/2; > re.r2=(r[i].r2+1)/2; > } > } > } > } > cout<<ti<<endl; > test--; > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator