์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต
-
[C++] ํ๋ก๊ทธ๋๋จธ์ค ์นด์นด์คํ๋ ์ฆ ์ปฌ๋ฌ๋ง๋ถ์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 10. 27. 18:11
#include #include using namespace std; int pic[100][100]; bool check[100][100]; int dir[4][2] = {{1,0},{0,1},{-1,0},{0,-1}}; int recursive(int x, int y, int m, int n, int value){ check[x][y] = true; int area = 0; for(int i=0; i= m || new_y >= n) continue; if(check[new_x][new_y] == true || pic[new_x][new_y] != value) continue; area += recursive(new_x, new_y, m, n, value); } return area + 1; } // ..
-
[C++] ์ผ์ฑ 1953. [๋ชจ์ SW ์ญ๋ํ ์คํธ] ํ์ฃผ๋ฒ ๊ฒ๊ฑฐ์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 10. 27. 18:10
#include #include #include #include using namespace std; int turnal[51][51] = { 0, }; bool visited[51][51] = { false, }; int dir[4][2] = { {0,1},{1,0},{0,-1},{-1,0} }; int N, M; bool connected(int before_dir, int type) { if (before_dir == 0) { if (type == 1 || type == 3 || type == 6 || type == 7) { return true; } } else if (before_dir == 1) { if (type == 1 || type == 2 || type == 4 || type == 7)..
-
[C++] ํ๋ก๊ทธ๋๋จธ์ค [2020์นด์นด์ค๊ณต์ฑ] ๋ฌธ์์ด ์์ถ์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 10. 27. 18:09
#include #include using namespace std; int str_zip(string s, int n) { string new_s; string tmp = s.substr(0, n); int count = 0, i; for (i = n; i 0) new_s.append(to_string(count+1) + tmp); else new_s.append(tmp); tmp = s.substr(i, n); count = 0; } } if (count > 0) new_s.append(to_string(count + 1) + tmp); ..
-
[C++] ์ผ์ฑ 5658. [๋ชจ์ SW ์ญ๋ํ ์คํธ] ๋ณด๋ฌผ์์ ๋น๋ฐ๋ฒํธ์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 10. 27. 18:09
#include #include #include #include using namespace std; int arr[28]; vector input; void rotate_square(int line_num, int count) { if (count != 0) { int tmp1 = arr[0]; int tmp2; for (int i = 0; i = 0; j--) { num..
-
[C++] ์ผ์ฑ 4008. [๋ชจ์ SW ์ญ๋ํ ์คํธ] ์ซ์ ๋ง๋ค๊ธฐ์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 10. 27. 18:08
#include #include using namespace std; int card[12]; int input[11]; int max_num = -100000000; int min_num = 100000000; int N; void solution(int size, int add, int sub, int mul, int div) { if (size == N-1) { int sum = 0; sum = card[0]; for (int n = 0; n < N-1; n++) { if (input[n] == 1) sum = sum + card[n + 1]; else if (input[n] == 2) sum = sum - card[n + 1]; else if (input[n] == 3) sum = sum * ca..
-
[C++] ์ผ์ฑ 1247. [S/W ๋ฌธ์ ํด๊ฒฐ ์์ฉ] 3์ผ์ฐจ - ์ต์ ๊ฒฝ๋ก์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 10. 27. 18:08
#include #include #include using namespace std; vector save; bool check[12] = { false, }; int min_dist; int cal_dist(pair a, pair b) { return abs(a.first - b.first) + abs(a.second - b.second); } void solution(int start_index, int dist, int size) { if (size == save.size() - 2) { dist += cal_dist(save[start_index], save[1]); if (min_dist > dist) min_dist = dist; return; } for (int i = 2; i < save...
-
[C++] ์ผ์ฑ 1244. [S/W ๋ฌธ์ ํด๊ฒฐ ์์ฉ] 2์ผ์ฐจ - ์ต๋ ์๊ธ์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 10. 27. 18:07
#include #include #include #include using namespace std; int max_number; int number_check[10] = {0, }; void swap(int& a, int& b) { int temp = a; a = b; b = temp; } void quiz(vector price, int change, int index) { if (change == 0) { int number = 0; int mul = 1; for (int i = price.size() - 1; i >= 0; i--) { number += price[i] * mul; mul *= 10; } if (max_number < number) max_number = number; return..
-
[C++] ์ผ์ฑ 1949. [๋ชจ์ SW ์ญ๋ํ ์คํธ] ๋ฑ์ฐ๋ก ์กฐ์ฑ์ฝ๋ฉํ ์คํธ/์ฝ๋ฉํ ์คํธ ์ฐ์ต 2020. 10. 27. 18:06
#include #include using namespace std; int arr[8][8]; int visit[8][8]; int dir[][2] = { {1,0},{0,1},{-1,0},{0,-1} }; int max_dist = 0; int N; int K; void solution(int x, int y, bool k, int dist) { if (x = N || y >= N) return; for (int i = 0; i = N || next_y >= N) continu..