标签:des style blog http io color ar os sp
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 21736 Accepted Submission(s): 8232
#include <iostream> #include <cstdio> #include <math.h> #include <string.h> #include <algorithm> #include <queue> #include <stack> using namespace std; int main() { int n; int i, j, k; char s[1000], t[1000]; char dd, ff; char map[1000][5]; int e=0; while(scanf("%d", &n)!=EOF) { stack<char>q; stack<char>p; memset(map, ‘\0‘, sizeof(map)); scanf("%s", s); scanf("%s", t); for(j=n-1; j>=0; j--) { p.push(t[j]); } e=0; for(i=0; i<n; i++) { q.push(s[i]); //cout<<s[i]<<"*"<<endl; strcat(map[e++], "in"); dd=q.top(); ff=p.top(); while( dd==ff && !q.empty() && !p.empty() ) { strcpy(map[e++], "out"); q.pop(); if(!q.empty()) dd=q.top(); p.pop(); if(!p.empty()) ff=p.top(); } } if(q.empty() && p.empty() ) { cout<<"Yes.\n"; for(k=0; k<e; k++) { cout<<map[k]<<endl; } } else { cout<<"No.\n"; } cout<<"FINISH\n"; } return 0; }
标签:des style blog http io color ar os sp
原文地址:http://www.cnblogs.com/yspworld/p/4100232.html