Skip to content

Instantly share code, notes, and snippets.

@majiang
Created January 12, 2015 13:25
Show Gist options
  • Save majiang/39f45866c60cd002c57b to your computer and use it in GitHub Desktop.
Save majiang/39f45866c60cd002c57b to your computer and use it in GitHub Desktop.
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
void main()
{
foreach (m; 0..readln().chomp().to!int())
{
bool[string] ans;
string str = readln().chomp();
foreach (i, c; str)
{
char[] v = str[0..i].dup;
char[] u = str[i..$].dup;
string w = v.idup;
string x = u.idup;
string y = v.reverse.idup;
string z = u.reverse.idup;
ans[w~x] = true;
ans[x~w] = true;
ans[y~z] = true;
ans[z~y] = true;
ans[w~z] = true;
ans[y~x] = true;
ans[z~w] = true;
ans[x~y] = true;
}
writeln(ans.length);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment