BOJ 9012
[백준 9012번-C++] 괄호
http://acmicpc.net/problem/9012 {코드} #include #include #include using namespace std; int main() { int n; string s, ans = ""; stack st; cin >> n; while (n--) { cin >> s; stack st; for (const char &c : s) { if (c == '(') { st.push(c); } else { if (!st.empty()) { st.pop(); } else { st.push('('); break; } } } if (!st.empty()) { ans += "NO\n"; } else { ans += "YES\n"; } } cout