์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต
-
[C++] ๋ฐฑ์ค 15685๋ฒ ๋๋๊ณค์ปค๋ธ์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 10. 27. 18:06
#include #include using namespace std; int coord[101][101]; int dir[][2] = { {1,0}, {0,-1}, {-1,0}, {0, 1} }; int turn_clock(int d) { return (d + 1) % 4; } void dragon_curve(vector dragon_dir, int x, int y, int d, int g, int g_temp) { if (g < g_temp) return; if (g_temp == 0) { coord[x][y] = 1; dragon_dir.push_back(d); coord[x + dir[d][0]][y + dir[d][1]] = 1; dragon_curve(dragon_dir, x + dir[d][0..
-
[C++] ๋ฐฑ์ค 14503๋ฒ. ๋ก๋ด ์ฒญ์๊ธฐ์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 10. 27. 18:05
#include using namespace std; int area[50][50]; int dir[4][2] = { {-1, 0}, {0, 1}, {1, 0}, {0, -1} }; int Cnt = 1; int turn_left(int d){ return (4 + d - 1) % 4; } int turn_back(int d) { return (4 + d - 2) % 4; } void solution(int r, int c, int d, int check) { area[r][c] = 2; int left_d = turn_left(d); int back_d = turn_back(d); if (area[r + dir[left_d][0]][c + dir[left_d][1]] == 0) { Cnt++; solu..
-
[C++] ์ผ์ฑ 1767. [SW Test ์ํ๋ฌธ์ ] ํ๋ก์ธ์ ์ฐ๊ฒฐํ๊ธฐ์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 10. 27. 18:05
#include #include #include using namespace std; int arr[12][12]; int T, N, res, pnum; bool dir_check(int x, int y, int dir) { if (dir == 1) { for (int i = y + 1; i < N; i++) { if (arr[x][i] != 0) return false; } } else if (dir == 2) { for (int i = x + 1; i < N; i++) { if (arr[i][y] != 0) return false; } } else if (dir == 3) { for (int i = 0; i < y; i++) { if (arr[x][i] != 0) return false; } } el..
-
[C++] ๋ฐฑ์ค 15686๋ฒ. ์นํจ๋ฐฐ๋ฌ์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 10. 27. 18:04
#include #include #include using namespace std; int N, M; int city[50][50]; int chicken_dist = 100000; vector houses; vector chickens; vector answer((13,13)); int find_dist() { int dist; int mini_dist; int total = 0; for (int i = 0; i < houses.size(); i++) { mini_dist = 100000; for (int j = 0; j < M; j++) { dist = abs(houses[i].first - answer[j].first) + abs(houses[i].second - answer[j].second);..
-
[C++] ์ผ์ฑ 2112. [๋ชจ์ SW ์ญ๋ํ ์คํธ] ๋ณดํธ ํ๋ฆ์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 10. 27. 18:03
#include #include using namespace std; int D, W, K; int input_array[13][20]; int min_count = 20; void input_A(int row) { for (int i = 0; i < W; i++) input_array[row][i] = 0; } void input_B(int row) { for (int i = 0; i < W; i++) input_array[row][i] = 1; } bool test_column(int j) { int max_count = 0; int count = 1; for (int i = 1; i < D; i++) { if (input_array[i - 1][j] == input_array[i][j]) count..
-
[C++] ์ผ์ฑ 2105. [๋ชจ์ SW ์ญ๋ํ ์คํธ] ๋์ ํธ ์นดํ์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 10. 27. 18:02
#include #include using namespace std; int N; int input_array[20][20]; int dessert[101] = { 0, }; int dArr[][2] = { { -1,1 },{ 1,1 },{ 1,-1 },{ -1,-1 } }; int first_x, first_y; int max_count = -1; void recursive(int a, int b, int n, int direction) { int x = a + dArr[direction][0]; int y = b + dArr[direction][1]; if (x >= N || y >= N || x 3) // ๋ฐฐ์ด ๋ฒ์๋ฅผ ๋๊ฑฐ๋ 4๋ฐฉํฅ ํ์ ์ ๋์์ ๊ฒฝ..
-
[C++] ํ๋ก๊ทธ๋๋จธ์ค. 2020 KAKAO BLIND RECRUITMENT ๊ธฐ๋ฅ๊ณผ ๋ณด ์ค์น์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 7. 22. 00:17
๋ค์ ํ์ด๋ณด๊ธฐ #include using namespace std; struct coord { int pillar; int beam; }; coord arr[101][101]; //๊ธฐ๋ฅ ์ธ์ธ ์กฐ๊ฑด ๋ฐ๋ฅ์ด๊ฑฐ๋ x=0, ๋ณด์ ํ์ชฝ ๋๋ถ๋ถ(์์ชฝ์ ์๋จ), ๋ค๋ฅธ ๊ธฐ๋ฅ ์ // ๋ณด ํ์ชฝ ๋๋ถ๋ถ์ด ๊ธฐ๋ฅ ์์ ์๊ฑฐ๋, ์์ชฝ ๋ ๋ถ๋ถ์ด ๋ค๋ฅธ ๋ณด์ ์ฐ๊ฒฐ bool pillar_check(int x, int y, int n) { if (y == 0) return true; if (arr[x][y - 1].pillar) return true; if (x > 0 && arr[x - 1][y].beam) return true; if (x < n && arr[x][y].beam) return true; return false; }..
-
[C++] ์ผ์ฑ 1249. [S/W ๋ฌธ์ ํด๊ฒฐ ์์ฉ] 4์ผ์ฐจ - ๋ณด๊ธ๋ก์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 7. 22. 00:14
์ ๋ ฅ๋ฐ๋ ๊ณผ์ ์ ์์ด์ ์ซ์๊ฐ ๋ถ์ด์ ์ฃผ์ด์ก๊ธฐ ๋๋ฌธ์ scanf๋ฅผ ํตํด ์ซ์ํ๋์ฉ ์ ๋ ฅ๋ฐ์. ์ฒ์์๋ DFS๋ฅผ ์ด์ฉํ ์์ ํ์์ผ๋ก ์งํํ์ง๋ง ์๊ฐ์ด๊ณผ ๋ฐ์ BFS์ DP๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ์์ผ๋ก ํด์ผ ํด๊ฒฐ๋จ. #include #include #include #include using namespace std; int N; int map[100][100]; int min_map[100][100]; int dir[4][2] = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} }; int findRoad() { queue q; q.push(make_pair(0, 0)); min_map[0][0] = 0; while (!q.empty()) { int x = q.front().first; int y = ..