3 [(]) (]) ([[]()])
No No Yes
/* 思路: 通过对输入的元素配对消元,然后检查所有的元素是否都已配对消元,从而输出最终的结果 */ #include<stdio.h> #define N 10000+10 char s[N]; int main() { int n; char c,*p; scanf("%d\n",&n); while(n--){ *s=getchar(); p=s+1; while((c=getchar())!=‘\n‘){ if(*(p-1)==c-1||*(p-1)==c-2) p--; else *p++=c; } if(p==s) printf("Yes\n"); else printf("No\n"); } }
原文:http://blog.csdn.net/user_longling/article/details/21977171