📄 3088722_ac_812ms_276k.cpp
字号:
#include <stdio.h>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
int len;
map <string,int> h;
int main()
{
int m, i, j, ans;
string t, p, q;
char str[75];
scanf("%d",&m);
while (m > 0)
{
m--;
ans = 1;
scanf("%s",str);
len = strlen(str);
h.clear();
t = str;
h[t] = 1;
for (i = 1; str[i]; i++)
{
t = "";p = "";
for (j = 0; j < i; j++)
{
t += str[j];
}
for (j = len-1; j >= i; j--)
{
t += str[j];
p += str[j];
}
for (j = 0; j < i; j++)
{
p += str[j];
}
if(h[t]==0)
{
h[t] = 1;
ans++;
}
if(h[p]==0)
{
h[p] = 1;
ans++;
}
t = "";p = "";
for(j = i; j < len; j++)
{
t += str[j];
}
for(j = i-1; j >= 0; j--)
{
t += str[j];
p += str[j];
}
for(j = i; j < len; j++)
{
p += str[j];
}
if(h[t]==0)
{
h[t] = 1;
ans++;
}
if(h[p]==0)
{
h[p] = 1;
ans++;
}
t = "";p = "";
for(j = i-1; j >= 0; j--)
{
t += str[j];
}
for(j = len-1; j >= i; j--)
{
p += str[j];
}
q = p+t;
if(h[q]==0)
{
h[q] = 1;
ans++;
}
q = t+p;
if(h[q]==0)
{
h[q] = 1;
ans++;
}
t = "";
for(j = i; j < len; j++)
{
t += str[j];
}
for(j = 0; j < i; j++)
{
t += str[j];
}
if(h[t]==0)
{
h[t] = 1;
ans++;
}
}
printf("%d\n",ans);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -