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:stlIn Reply To:stl Posted by:Yt_zp at 2017-04-10 14:57:38 #include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <string> using namespace std; #define pb(x) q.push_back(x) vector<string>q; int main(){ int loop; scanf("%d",&loop); string s; while(loop--){ q.clear(); cin>>s; int len=s.length(); int tot=0; string ss=s; reverse(ss.begin(),ss.end()); pb(s);pb(ss); for(int i=1;i<len;++i){ string a,b,c,d,t; a=b=s.substr(0,i); reverse(b.begin(),b.end()); c=d=s.substr(i,len-1); reverse(d.begin(),d.end()); pb(a+d);pb(b+c);pb(b+d); pb(c+a);pb(c+b);pb(d+a); } sort(q.begin(),q.end()); vector<string>::iterator it=unique(q.begin(),q.end()); int ans=distance(q.begin(),it); printf("%d\n",ans); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator