mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-18 13:12:01 +00:00
35 lines
734 B
C++
35 lines
734 B
C++
#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]);
|
|
}
|
|
else if (st.empty() || s[i] == ')' && st.top() != '(' || s[i] == ']' && st.top() != '[') {
|
|
cout << "No" << endl;
|
|
goto end;
|
|
}
|
|
else {
|
|
st.pop();
|
|
}
|
|
}
|
|
if (st.empty()) {
|
|
cout << "Yes" << endl;
|
|
}
|
|
else {
|
|
cout << "No" << endl;
|
|
}
|
|
end:;
|
|
}
|
|
return 0;
|
|
}
|