标签:clu iostream pop ios fast images set ++ color
#include<iostream> #include<cstdio> #include<cstring> #include<sstream> #include<algorithm> #include<queue> #include<vector> #include<cmath> #include<map> #include<stack> #include<set> #include<fstream> #include<memory> #include<string> using namespace std; typedef long long LL; #define MAXN 10 #define INF 1000000009 /* 判断出栈顺序是否合法 */ char a[MAXN], b[MAXN], n; vector<string> ans; int main() { while (scanf("%d%s%s", &n, a, b) != EOF) { int i = 0, j = 0; stack<int> s; ans.clear(); for (j = 0; j < n; j++) { if (s.size() && s.top() == b[j]) { ans.push_back("out"); s.pop(); continue; } if (a[i] == b[j]) { ans.push_back("in"); ans.push_back("out"); i++; continue; } while (i < n&&a[i] != b[j]) { ans.push_back("in"); s.push(a[i++]); } if (i == n) { printf("No.\n"); break; } else { ans.push_back("in"); ans.push_back("out"); i++; } } if (j == n) { printf("Yes.\n"); for (i = 0; i < ans.size(); i++) cout << ans[i] << endl; } printf("FINISH\n"); } }
标签:clu iostream pop ios fast images set ++ color
原文地址:http://www.cnblogs.com/joeylee97/p/6736825.html