Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:stl

Posted by Yt_zp at 2017-04-10 14:57:43 on Problem 3007
In 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator