题目
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/286979091c3f09effd436a44ccc30c4a.png)
思路
代码
#include <iostream>
#include <stack>
#include <vector>
#define MAXX 100005
using namespace std;
int main()
{
int N;
string in, out;
while (cin >> N)
{
vector<string> v;
stack<int> s;
cin >> in >> out;
if (N == 0)
{
cout << "Yes." << endl;
} else
{
for (int i = 0; i < in.length(); ++i)
{
s.push(in[i] - '0');
v.push_back("in");
while (out.length() != 0 && s.size() != 0 && (out[0] - '0') == s.top())
{
s.pop();
v.push_back("out");
out.erase(0, 1);
}
}
if (out.length() != 0)
cout << "No." << endl;
else
{
cout << "Yes." << endl;
for (int i = 0; i < v.size(); ++i)
cout << v[i] << endl;
}
}
cout << "FINISH" << endl;
}
return 0;
}