Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 20497 Accepted Submission(s): 7701
#include <stdio.h> #include <stack> #include <string.h> using namespace std; const char ch[2][4] = {"in", "out"}; int main() { stack<char> s; char s1[105], s2[105], t; int n, i, j, k, ans[210]; while (~scanf("%d%s%s", &n, s1, s2)) { while (!s.empty()) { s.pop(); } memset(ans, 0, sizeof(ans)); i = j = k = 0; while (i < n) { s.push(s1[i]); k++; while (!s.empty()) { t = s.top(); if (t == s2[j]) { s.pop(); ans[k++] = 1; j++; } else break; } i++; } while (!s.empty() && j < n) { t = s.top(); if (t == s2[j]) { s.pop(); ans[k++] = 1; j++; } else break; } if (j == n) { puts("Yes."); for (i = 0; i < k; i++) puts(ch[ans[i]]); } else { puts("No."); } puts("FINISH"); } return 0; }
hdu 1022 Train Problem I,布布扣,bubuko.com
原文:http://www.cnblogs.com/jecyhw/p/3897530.html