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:Accepts了,但是花的时间很多,请问如何优化?In Reply To:Accepts了,但是花的时间很多,请问如何优化? Posted by:xiaohao2009 at 2009-04-28 18:09:23 > 这条是水题,Accepts了,但是却花了641MS,感觉好多啊,请问如何优化?完整代码如下: > #include<iostream> > #include<string> > using namespace std; > > int main() > { > int n,i,j,k,flag,m; > string str; > cin>>n; > for(k=0;k<n;k++) > { > cin>>str; > for(j=0;j<str.size();j=m) > { > i=j+1; > flag=1; > for(i=j+1,flag=1;str[i]==str[j];i++) > flag++; > m=i; > cout<<flag<<str[j]; > } > cout<<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