일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- RTL
- fsb
- House of Orange
- 동적 계획법
- ROP
- OOB
- 브루트 포스
- 에라토스테네스의 체
- 다이나믹 프로그래밍
- 스택
- 분할 정복
- 연결리스트
- BOF
- heap
- 이분 탐색
- 백트래킹
- 스위핑 알고리즘
- 큐
- 이진트리
- 문자열 처리
- off by one
- 완전 탐색
- 이진 탐색
- BFS
- tcache
- syscall
- 투 포인터
- 포맷스트링버그
- 수학
- DFS
Archives
- Today
- Total
SDJ( 수돈재 아님 ㅎ )
[C++] 9012 - 괄호 본문
문제 링크 : https://www.acmicpc.net/problem/9012
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include<iostream>
#include<algorithm>
#include<string>
#include<stack>
#define endl '\n'
using namespace std;
bool M(const string& S)
{
const string opening("("), closing(")");
stack<char> Stack;
for(int i = 0; i < S.size(); ++i)
{
if(opening.find(S[i]) != -1)
Stack.push(S[i]);
else
{
if(Stack.empty()) return false;
Stack.pop();
}
}
return Stack.empty();
}
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string K;
int n;
cin >> n;
while(n--)
{
cin >> K;
if(M(K))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
'알고리즘 > Backjoon' 카테고리의 다른 글
[C++] 1011 - Fly me to the Alpha Centauri (0) | 2020.01.11 |
---|---|
[C++] 4949 - 균형잡힌 세상 (0) | 2020.01.11 |
[C] 1932 - 정수 삼각형 (0) | 2020.01.11 |
[Python3] 2193 - 이친수 (0) | 2020.01.11 |
[C] 1149 - RGB거리 (0) | 2020.01.11 |
Comments