#include <bits/stdc++.h>
using namespace std;
string s,t;
vector<int> ans;
int n;
void rec(int i,int o,unsigned int num,string tmp,string res){
if(i==n&&o==n){
if(res==t){ans.push_back(num);return;}
else return;
}
else if(t.compare(0, res.size(), res) != 0)return;
if(i<n){
rec(i+1,o,(num<<1),tmp+s[i],res);
}
if(o<i){
char c=tmp[tmp.size()-1];
rec(i,o+1,((num<<1) + 1),tmp.substr(0,tmp.size()-1),res+c);
}
}
int main(){
ios::sync_with_stdio(0);
while(cin>>ws>>s>>ws>>t){
ans.clear();
n=s.size();
if(s.size()==t.size())
rec(0,0,0,string(),string());
sort(ans.begin(),ans.end());
cout<<'['<<endl;
for(auto x:ans){
for(int i=2*n-1;i>0;i--)
cout<<(((1<<i)&x)?'o':'i')<<' ';
cout<<(x&1?'o':'i')<<endl;
}
cout<<']'<<endl;
}
return 0;
}
Comments
Post a Comment