生成した文字列を 2つ連結して、それを並べた文字列を用意すると、
新たな候補の文字列がそれに含まれるかどうかが判定できます。
2つ連結するのは円順列による一致を調べるためです。
コード:
#include <iostream>
#include <string>
#include <algorithm> // sort, next_permutation
using namespace std;
int main()
{
string s, t = "";
cout << ">> ";
cin >> s;
sort(begin(s), end(s));
auto a = begin(s) + 1, b = end(s);
do {
if (t.find(s) == string::npos) {
cout << s << endl;
t += s + s + " ";
}
} while (next_permutation(a, b));
}
単純な方法なので、30桁は厳しいでしょう。
実行例
コード:
>> 111111000000
000000111111
000001011111
000001101111
000001110111
000001111011
000001111101
000010011111
000010101111
000010110111
000010111011
000010111101
000011001111
000011010111
000011011011
000011011101
000011100111
000011101011
000011101101
000011110011
000011110101
000011111001
000100011111
000100101111
000100110111
000100111011
000100111101
000101001111
000101010111
000101011011
000101011101
000101100111
000101101011
000101101101
000101110011
000101110101
000101111001
000110001111
000110010111
000110011011
000110011101
000110100111
000110101011
000110101101
000110110011
000110110101
000110111001
000111000111
000111001011
000111001101
000111010011
000111010101
000111011001
000111100101
000111101001
001001001111
001001010111
001001011011
001001011101
001001100111
001001101011
001001101101
001001110011
001001110101
001010010111
001010011011
001010011101
001010100111
001010101011
001010101101
001010110011
001010110101
001011001011
001011001101
001011010011
001011010101
001100110011
001100110101
001101001101
001101010101
010101010101