algorithm'''problem solve
[백준]9012-괄호(설명X)
JunHwa Park
2020. 2. 1. 16:41
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <iostream> #include <stack> using namespace std; int main() { int argc; cin >> argc; for (size_t i = 0; i < argc; i++) { string str; cin >> str; stack<char> vps; for (size_t j = 0; j < str.size(); j++) { if (str[j] == '(') vps.push('('); else if (vps.size() == 0) { vps.push('('); break; } else vps.pop(); } if (vps.size() > 0) cout << "NO" << endl; else cout << "YES" << endl; } return 0; } | cs |