STK
-
쇠막대기백준알고리즘 2019. 9. 8. 15:18
#include #include #include #include using namespace std; int main(void) { int nstick = 0;//총 막대기 int result = 0; string str; stack stk; cin >> str; vector lstick;//1개의 레이저가 통과하는 막대기 for (int i = 0; i < str.length(); i++) { if (str[i] == '(') stk.push(str[i]); else { if (str[i - 1] == str[i]) { stk.pop(); nstick++; } else { stk.pop(); lstick.push_back(s.size()); }//스택에 남아있는 '('수 = 레이저가 통과하는 막대기 수..