参考:http://www.cnblogs.com/xiaocai905767378/archive/2011/05/29/2062007.html
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <stack>
#include <iomanip>
using namespace std;
///
#define INF 0xffffff7
#define maxn 300
///
int n;
char str[maxn];
int main()
{
///
int i, j;
char *p1, *p2;
scanf("%d", &n);
getchar();
while (n--)
{
gets(str);
p1 = str;
while (*p1 != '\0')
{
if ((*p1 == '(' && *(p1 + 1) == ')') || (*p1 == '[' && *(p1 + 1) == ']'))
{
*p1 = '\0';
p2 = p1 + 2;
p1 = str;
strcat(p1, p2);
}
else
p1++;
}
if( str[0] == '\0' )
printf("Yes\n");
else
printf("No\n");
}
///
return 0;
}