스택 괄호문제!!
#include<iostream>
#include<string>
using namespace std;
int main() {
char stack[51];
string str;
int empty = 0;
int n;
int top = -1;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> str;
for (int i = 0; i < (int)str.length(); i++) {
if (str.at(i) == '(')
stack[++top]= str.at(i);
else
{
if (top == -1)
{
empty = 1;
}
else stack[top--];
}
}
if (top == -1 && empty == 0)
cout << "YES" << endl;
else
cout << "NO" << endl;
empty = 0;
top = -1;
}
return 0;
}