#include <iostream>
#include <string>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
cin.ignore();
for (int i = 0; i < N; i++)
{
string str;
getline(cin, str);
int open = 0;
for(char ch : str)
{
if (ch == '(')
{
open++;
}
else if (ch == ')')
{
open--;
if (open < 0)
{
break;
}
}
}
if (open == 0)
{
cout << "YES\n";
}
else
{
cout << "NO\n";
}
}
return 0;
}
'개발일지 > 알고리즘' 카테고리의 다른 글
백준 1158번 : 요세푸스 문제 (1) | 2025.01.25 |
---|---|
백준 1874번 : 스택 수열 (0) | 2025.01.25 |
백준 10867번 : 중복 빼고 정렬하기 (0) | 2025.01.23 |
백준 11651번 : 좌표 정렬하기 2 (0) | 2025.01.23 |
백준 1181번 : 단어 정렬 (0) | 2025.01.22 |