본문 바로가기

BaekJoon125

5014 : 스타트링크 (C++) 5014번: 스타트링크 첫째 줄에 F, S, G, U, D가 주어진다. (1 ≤ S, G ≤ F ≤ 1000000, 0 ≤ U, D ≤ 1000000) 건물은 1층부터 시작하고, 가장 높은 층은 F층이다. www.acmicpc.net 스위프트 공부좀 해야 허는디 #include #include using namespace std; int stairs[1000001]; bool visit[1000001]; int F, S, G; // 층수, 시작층, 도착층 int upDown[2]; // 위, 아래 queue q; void bfs() { q.push(S); visit[S] = true; while(!q.empty()) { int x = q.front(); q.pop(); if(x == G) { // x가 .. 2021. 3. 7.
3055 : 탈출 (C++) 3055번: 탈출 사악한 암흑의 군주 이민혁은 드디어 마법 구슬을 손에 넣었고, 그 능력을 실험해보기 위해 근처의 티떱숲에 홍수를 일으키려고 한다. 이 숲에는 고슴도치가 한 마리 살고 있다. 고슴도치는 제 www.acmicpc.net 푸는데 너무 오래걸렸다. #include #include #include using namespace std; char map[50][50]; bool visit[50][50]; int result[50][50]; queue q; int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; int R, C; int xS, yS; // 임시 저장공간 큐의 맨 뒤에 S를 넣기 위함 int xR, yR; // 결과값을 위한 임시 저장 공간 결과.. 2021. 3. 3.
14940 : 쉬운 최단거리 (C++) 14940번: 쉬운 최단거리 지도의 크기 n과 m이 주어진다. n은 세로의 크기, m은 가로의 크기다.(2 ≤ n ≤ 1000, 2 ≤ m ≤ 1000) 다음 n개의 줄에 m개의 숫자가 주어진다. 0은 갈 수 없는 땅이고 1은 갈 수 있는 땅, 2는 목표지점이 www.acmicpc.net #include #include using namespace std; int map[1000][1000]; bool visit[1000][1000]; int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; queue q; int n, m; void bfs() { while(!q.empty()) { int x = q.front().first; int y = q.front().sec.. 2021. 3. 2.
11607 : Grid (C++) 11607번: Grid Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. The first line of input contains two space-separated integers n and m (1≤n,m≤500), indicating the size of the grid. It is guaranteed th www.acmicpc.net 그래프문제 조아 #include #include #include using namespace std; int n, m; int map[500][500]; bool visit[500][500]; int resu.. 2021. 3. 2.
11370 : Spawn of Ungoliant (C++) 11370번: Spawn of Ungoliant The first line of an input case is of the form W H, where W is the width of the map and H is the height. The next H lines contain strings of length W specifying the layout of Mirkwood. An S character represents a spider-infested tree, and an T character re www.acmicpc.net 쉬운 내용의 BFS라서 설명없이 그냥 코드만 올림 #include #include #include #include using namespace std; int W, H; int.. 2021. 2. 27.
5378 : Hex (C++) 5378번: Hex Hex is a game for two players, played on a diamond-shaped board with hexagonal cells. At the start of the game, all cells are empty. Each player in turn puts a stone of his own color (black or white) in any empty cell. The goal for Black is to connect the www.acmicpc.net 처음에 8방향(상하좌우 + 대각선)으로 탐색할 수 있는 줄 알고 8방향을 넣었다가 틀려서 맞왜틀하다가 문제 다시 읽고 그림 다시 보니 6각형이라 6방향으로만 갈 수밖에 없길래 6방향으로 고쳐서 다시 풀었더니.. 2021. 2. 27.
6764 : Sounds fishy! (C++) 6764번: Sounds fishy! The output is one of four possibilities. If the depth readings are increasing, then the output should be Fish Rising. If the depth readings are decreasing, then the output should be Fish Diving. If the depth readings are identical, then the output should b www.acmicpc.net 배열에 4개의 값을 입력 받음과 동시에 두번째 배열부터 앞의 배열과 크기를 비교하면서 증가 하는 순으로 가면 결과값인 3이 나올 것이고 감소 하는 순으로 가면 결과값이 30이 나올 것이며.. 2021. 2. 26.
6186 : Best Grass (C++) 6186번: Best Grass Bessie is planning her day of munching tender spring grass and is gazing out upon the pasture which Farmer John has so lovingly partitioned into a grid with R (1 = 0 && nc > temp; for(int c = 0; c < C; c++) { map[r][c.. 2021. 2. 26.
5011 : Robots on a grid (C++) 5011번: Robots on a grid You have recently made a grid traversing robot that can find its way from the top left corner of a grid to the bottom right corner. However, you had forgotten all your AI programming skills, so you only programmed your robot to go rightwards and downwards www.acmicpc.net 영어 문제라 읽는데 시간을 보내고 대충읽고 문제를 푼 후(사실 못 읽은것) 틀린다음에야 제대로 읽어보고 5번만에야 맞은 문제다. 사실 문제만 제대로 읽고 이해했으면 한번에 맞췄을 것 .. 2021. 2. 26.