📄 zju1004.txt
字号:
/*
农夫三拳@seu
drizzlecrj.gmail.com
2007-03-02
*/
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
string source, dest;
string obj, mid;
vector<char> oper;
void Output()
{
//cout << oper[0];
int size = oper.size();
for(int i = 0; i < size; ++i)
cout << oper[i] << " " ;
cout << endl;
}
void Simulate()
{
if(obj.length() == source.length())
{
if(obj == source)
Output();
}
if(!dest.empty())
{
char top = dest[0];
dest = dest.substr(1);
mid += top;
oper.push_back('i');
Simulate();
oper.pop_back();
mid = mid.substr(0, mid.size() - 1);
dest = top + dest;
}
if(!mid.empty())
{
char top = mid[mid.size() - 1];
obj += top;
mid = mid.substr(0, mid.size() - 1);
oper.push_back('o');
Simulate();
oper.pop_back();
mid += top;
obj = obj.substr(0, obj.size() - 1);
}
}
int main()
{
while(cin >> dest >> source)
{
cout << "[" << endl;
if(source.length() == dest.length())
{
string tmpSource = source;
string tmpDest = dest;
sort(tmpSource.begin(), tmpSource.end());
sort(tmpDest.begin(), tmpDest.end());
if(tmpSource == tmpDest)
{
mid = obj = "";
oper.clear();
Simulate();
}
}
cout << "]" << endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -