题意
传送门 POJ 3007
题解
POJ 不支持 unordered_set;string + set TLE;直接 string 排序去重过了。
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define abs(x) ((x) < 0 ? -(x) : (x))
#define INF 0x3f3f3f3f
#define delta 0.85
using namespace std;
string S;
string st[75 * 8];
void solve(){
int n = S.length();
int j = 0;
for(int i = 1; i < n; i++){
string s1 = S.substr(0, i), r1 = s1;
string s2 = S.substr(i, n - i), r2 = s2;
reverse(r1.begin(), r1.end()); reverse(r2.begin(), r2.end());
st[j++] = s1 + s2; st[j++] = s2 + s1;
st[j++] = s1 + r2; st[j++] = r2 + s1;
st[j++] = r1 + s2; st[j++] = s2 + r1;
st[j++] = r1 + r2; st[j++] = r2 + r1;
}
sort(st, st + j);
printf("%d\n", unique(st, st + j) - st);
}
int main(){
int t;
scanf("%d", &t);
while(t--){
cin >> S;
solve();
}
return 0;
}