코테 & 알고리즘/백준

코테 & 알고리즘/백준

[백준] 실버4. 균형잡힌 세상(4949번)

#include #include #include #include int main() { std::ios::sync_with_stdio(0); std::cin.tie(0); while (true) { std::string str_buf; getline(std::cin, str_buf); if (str_buf == ".") break; std::stack s; bool isValid = true; for (int i = 0; str_buf[i] != '\0'; ++i) { char c = str_buf[i]; if (c == '(' || c == '[') s.push(c); else if (c == ')') { if (s.empty() || s.top() != '(') { isValid = false; br..

코테 & 알고리즘/백준

[백준] 실버1. 미로 탐색(2178번)

#include #include #include using namespace std; #define X first #define Y second // pair에서 first, second를 줄여서 쓰기 위해서 사용 int main(void) { ios::sync_with_stdio(0); cin.tie(0); int n = 0, m = 0; // n = 행의 수, m = 열의 수 int dx[4] = { 1,0,-1,0 }; int dy[4] = { 0,1,0,-1 }; // 상하좌우 네 방향을 의미 //cout n >> m; //cout > board[i][j]; queue Q; //vis[0][0] = 0; // (0, 0)을 방문했다고 명시 Q.push({ 0, 0 }); // 큐에 시작점인 (0,..

코테 & 알고리즘/백준

[백준] 실버1. 그림(1926번)

#include #include #include using namespace std; #define X first #define Y second // pair에서 first, second를 줄여서 쓰기 위해서 사용 int main(void) { ios::sync_with_stdio(0); cin.tie(0); int n = 0, m = 0; // n = 행의 수, m = 열의 수 int dx[4] = {1,0,-1,0}; int dy[4] = {0,1,0,-1}; // 상하좌우 네 방향을 의미 //cout n >> m; //cout > board[i][j]; int count = 0; int max_area = 0; for (int i = 0; i < n; i++) { for (int j = 0; j <..

코테 & 알고리즘/백준

[백준] 실버5. 줄세우기(10431번)

#include int main() { int P, T, heights[20], steps; scanf("%d", &P); // 테스트 케이스의 수 입력 for (int i = 0; i 0 && heights[k] < heights[k - 1]) { // 현재 아이의 키가 앞의 아이의 키보다 작으면 ..

lwj789
'코테 & 알고리즘/백준' 카테고리의 글 목록