์ฝ๋ฉํ ์คํธ
-
[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๋ฐฉํฅ ํ์ ์ ๋์์ ๊ฒฝ..
-
์ฐ์ ์์ํ์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ํ 2020. 9. 6. 04:48
#include #include using namespace std; struct Coord { int x; int y; Coord(int _x, int _y) { x = _x; y = _y; } }; struct Comp { // return ์ด ๋ฎ์ ์์ผ๋ก ๋ฝ๋๋ค(์ค๋ฆ์ฐจ์) bool operator()(struct Coord a, struct Coord b) { if (a.x == b.x) return a.y b.x; // x๋ ์ค๋ฆ์ฐจ์ } }; int main() { priority_queue pq_1; // ์ฐ์ ์์ํ๋ ๊ธฐ๋ณธ์ ์ผ๋ก ๋ด๋ฆผ์ฐจ์ pq_1.push(5); pq_1.push(2..