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:哪位给个快点的方法啊.. 我居然3000多ms, 太丢脸了. 话说本人很懒,用stl了.In Reply To:哪位给个快点的方法啊.. 我居然3000多ms, 太丢脸了. 话说本人很懒,用stl了. Posted by:lijinwu at 2010-04-12 18:01:20 > #include <iostream> > #include <sstream> > #include <string> > using namespace std; > > int main() > { > freopen("in.txt","r",stdin); > freopen("out.txt","w",stdout); > int n; > string str; > string res; > scanf("%d",&n); > while(n--) > { > cin >> str; > res.clear(); > int index=0; > int count=1; > for(int i=1;i!=str.size()+1;++i) > { > if(str[i]!=str[index]) > { > stringstream s; > string ss; > s << count; > s >> ss; > res+=ss+str[index]; > index=i; > count=1; > } > else > { > count++; > } > } > cout << res << endl; > } > return 0; > } str.size() 不要写到循环里面。 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator