하다보니
3986번-좋은 단어 본문
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main() {
int n;
int ans = 0;
cin >> n;
while (n--) {
string a;
cin >> a;
stack<char> s;
for (auto c : a) {
if (!s.empty() && s.top() == c)s.pop();
else s.push(c);
}
if (s.empty())ans++;
}
cout << ans << "\n";
}
'알고리즘 풀이 > 백준' 카테고리의 다른 글
1182번-부분수열의 합 (0) | 2022.03.08 |
---|---|
n과 m(1) (0) | 2022.03.08 |
3986번-균형 잡힌 세상 (0) | 2022.03.07 |
2630번-색종이 만들기 (0) | 2022.02.18 |
6593번-상범 빌딩 (0) | 2022.02.17 |