Created
January 12, 2015 13:25
-
-
Save majiang/39f45866c60cd002c57b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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