0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-27 07:31:58 +00:00
OI-codes/Luogu/UVA673/UVA673.cpp

32 lines
702 B
C++
Raw Normal View History

#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
getchar();
while (t--) {
string s;
stack<char> st;
getline(cin, s);
for (int i = 0; i < s.size(); i++) {
if (s[i] == '(' || s[i] == '[') {
st.push(s[i]);
2021-11-19 09:01:13 +00:00
} else if (st.empty() || s[i] == ')' && st.top() != '(' || s[i] == ']' && st.top() != '[') {
cout << "No" << endl;
goto end;
2021-11-19 09:01:13 +00:00
} else {
st.pop();
}
}
if (st.empty()) {
cout << "Yes" << endl;
2021-11-19 09:01:13 +00:00
} else {
cout << "No" << endl;
}
end:;
}
return 0;
}