hdu 1022
#include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<cctype> #include<algorithm> #include <vector> #include <stack> #include <queue> using namespace std; #define INF 0x3f3f3f3f #define N 550 int main() { int n; char a[N], b[N]; stack <char> s; queue <char> q; while(~scanf("%d", &n)) { memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); scanf("%s%s", a, b); while(!s.empty()) s.pop(); while(!q.empty()) q.pop(); int i, j; i=j=0; while(i<n) { s.push(a[i]); q.push(1); while(!s.empty()&&s.top()==b[j]) { s.pop(); q.push(0); j++; } i++; } if(s.empty()) { printf("Yes.\n"); while(!q.empty()) { if(q.front()) printf("in\n"); else printf("out\n"); q.pop(); } } else printf("No.\n"); printf("FINISH\n"); } return 0; }
时间: 2024-10-10 07:35:18