From c29e4e8a63ef1fcb5be01445150e90ef89a5108a Mon Sep 17 00:00:00 2001 From: jjiijj78 Date: Sat, 8 Feb 2020 19:09:47 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Create=2015683=EA=B0=90=EC=8B=9C=5F?= =?UTF-8?q?=EC=94=A8=EC=9E=91.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\213\234_\354\224\250\354\236\221.cpp" | 201 ++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 "mose/15683\352\260\220\354\213\234_\354\224\250\354\236\221.cpp" diff --git "a/mose/15683\352\260\220\354\213\234_\354\224\250\354\236\221.cpp" "b/mose/15683\352\260\220\354\213\234_\354\224\250\354\236\221.cpp" new file mode 100644 index 0000000..2cbe569 --- /dev/null +++ "b/mose/15683\352\260\220\354\213\234_\354\224\250\354\236\221.cpp" @@ -0,0 +1,201 @@ +#define _CRT_SECURE_NO_WARNINGS +#include +#include +#include +#include +#include +using namespace std; + +int N, M; +int arr[10][10]; +int arr_copy[10][10]; +int location_x, location_y, number,direction; +int zero_count, tot_zero_count=10000; + + struct cctv{ + int location_x; + int location_y; + int number; + int direction = 0; +}; +vector vec; +cctv temp; +map number_pair; +struct stacks { + int number; + int direction; +}; +stacks stack_temp; +vector one_line; +vector> tot_line; + +vector dir; +void function2(int count, int direction); +int function(); +void draw(int location_x, int location_y, int number, int direction); +void copys(); +void print(); + +int main() { + + + + //1¹ø ÇÑÂÊ ,2¹ø ÆòÇà, 3¹ø Á÷°¢, 4¹ø 3¹æÇâ, 5¹ø ¹æÇâ + //scanf("%d %d",&N,&M); + cin >> N >> M; + + for (int i=0; i < N; i++) { + for (int j=0; j < M; j++){ + + cin >> arr[i][j]; + + if (arr[i][j] != 0 && arr[i][j]!=6) + { + temp.location_x = i; + temp.location_y = j; + temp.number = arr[i][j]; + vec.push_back(temp); + } + } + } + + number_pair.insert(pair(1, 4)); + number_pair.insert(pair(2, 2)); + number_pair.insert(pair(3, 4)); + number_pair.insert(pair(4, 4)); + number_pair.insert(pair(5, 1)); + + int count = 0; + int direction = 0; + function2(count, direction); + function(); + cout << tot_zero_count; + return 0; + +} +void function2(int count, int direction) {//vectorÀÇ ¸î¹øÂ°, ¹æÇâ + if (count < vec.size()) { + int number = vec.at(count).number; + for (int direction = 0; direction < number_pair[number]; direction++) + { + + stack_temp.direction = direction; + stack_temp.number = number; + one_line.push_back(stack_temp); + function2(count+1, direction); + one_line.pop_back(); + } + + } + else if (count == vec.size()) { + tot_line.push_back(one_line); + + } + +} +int function() { + for (int i = 0; i < tot_line.size(); i++) + { + print(); + copys(); + print(); + cout << tot_line.at(i).size(); + for (int j = 0; j < tot_line.at(i).size();j++) { + cout << "(" << tot_line.at(i).at(j).number << "," << tot_line.at(i).at(j).direction << ")"; + + } + cout << endl; + for (int j = 0; j < tot_line.at(i).size(); j++) { + + location_x = vec.at(j).location_x; + location_y = vec.at(j).location_y; + number = tot_line.at(i).at(j).number; + direction = tot_line.at(i).at(j).direction; + draw(location_x, location_y, number, direction); + } + print(); + zero_count = 0; + for (int i = 0; i < N; i++) { + for (int j = 0; j < M; j++) { + if (arr_copy[i][j] == 0) { + zero_count += 1; + } + } + } + tot_zero_count = tot_zero_count > zero_count ? zero_count : tot_zero_count; + } + return tot_zero_count; +} + + +void draw(int location_x,int location_y,int number, int direction) { + int direction_all; + dir + if (number == 1) + { + dir.push_back(direction); + }else if (number == 2) { + + dir.push_back(direction); + dir.push_back(direction+2); + }else if (number == 3) { + dir.push_back(direction); + dir.push_back((direction + 1) % 4); + }else if (number == 4) { + dir.push_back(direction); + dir.push_back((direction + 1) % 4); + dir.push_back((direction + 3) % 4); + }else if (number == 5) { + dir.push_back(direction); + dir.push_back((direction + 1) % 4); + dir.push_back((direction + 2) % 4); + dir.push_back((direction + 3) % 4); + } + + + for (int m = 0; m < dir.size(); m++) { + direction_all = dir.at(m); + if (direction_all == 0) {//draw Top + for (int i = location_x; i >=0; i--) { + if (arr_copy[i][location_y] == 6)break; + arr_copy[i][location_y] = 1; + } + } + if (direction_all == 1) {//draw Right + for (int i = location_y; i < M; i++) { + if (arr_copy[location_x][i] == 6)break; + arr_copy[location_x][i] = 1; + } + } + if (direction_all == 2) {//draw Down + for (int i = location_x; i < N; i++) { + if (arr_copy[i][location_y] == 6)break; + arr_copy[i][location_y] = 1; + } + } + if (direction_all == 3) {//draw Left + for (int i = location_y; i >=0; i--) { + if (arr_copy[location_x][i] == 6)break; + arr_copy[location_x][i] = 1; + } + } + } + + +} +void copys() { + for (int i = 0; i < N; i++) { + for (int j = 0; j < M; j++) { + arr_copy[i][j] = arr[i][j]; + } + } +} +void print() { + cout << endl; + for (int i = 0; i < N; i++) { + for (int j = 0; j < M; j++) { + cout << arr_copy[i][j]; + } + cout << endl; + } +} \ No newline at end of file From a5d0aa3694ac8e8a93858c55ce7dd84b87b4553c Mon Sep 17 00:00:00 2001 From: jjiijj78 Date: Mon, 17 Feb 2020 07:30:17 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=ED=8A=B8=EB=A6=AC=EC=9D=98=EC=A7=80?= =?UTF-8?q?=EB=A6=84=20=EB=AF=B8=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 미완성 --- ...4\354\235\230\354\247\200\353\246\204.cpp" | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 "mose/\355\212\270\353\246\254\354\235\230\354\247\200\353\246\204.cpp" diff --git "a/mose/\355\212\270\353\246\254\354\235\230\354\247\200\353\246\204.cpp" "b/mose/\355\212\270\353\246\254\354\235\230\354\247\200\353\246\204.cpp" new file mode 100644 index 0000000..af639d3 --- /dev/null +++ "b/mose/\355\212\270\353\246\254\354\235\230\354\247\200\353\246\204.cpp" @@ -0,0 +1,58 @@ + +#include +#include +#include +using namespace std; + + +vector leaf_node; +int n; +int** arr; + +void allocation(); +void prints(); +void find_lnode(); +int main() { + + allocation(); + prints(); + find_lnode(); + return 0; +} + +void allocation() { + cin >> n; + arr = new int*[n - 1]; + for (int i = 0; i < n - 1; i++) { + arr[i] = new int[3]; + } + for (int i = 0; i < n - 1; i++) { + for (int j = 0; j < 3; j++) { + cin >> arr[i][j]; + } + } + +} +void prints() { + + for (int i = 0; i < n - 1; i++) { + for (int j = 0; j < 3; j++) { + cout << arr[i][j]; + } + cout << endl; + } + cout << "a" << endl; +} +void find_lnode() { + + for (int i = 0; i < n - 1; i++) { + leaf_node.push_back(arr[i][1]); + for (int j = 0; j < n - 1; j++) + { + if (arr[j][0] == arr[i][1]) { + leaf_node.pop_back(); + break; + } + } + } +} \ No newline at end of file