diff --git a/src/week5/BOJ17406/BOJ17406_V1.cpp b/src/week5/BOJ17406/BOJ17406_V1.cpp new file mode 100644 index 0000000..62c5068 --- /dev/null +++ b/src/week5/BOJ17406/BOJ17406_V1.cpp @@ -0,0 +1,85 @@ +#include +using namespace std; +int A[101][101]; +int N,M,C; +int rotate_input[6][3]; +int ret = INT_MAX; + +void run_rotate(int y, int x, int n){ + int temp1[101][101]; + memcpy(temp1, A, sizeof(A)); + for (int i=1; i<=n; i++) { + int top = y-i; + int bot = y+i; + int left = x-i; + int right = x+i; + vector> idx; + for (int j=left; j<=right; j++) + idx.push_back({top,j}); + for (int j=top+1; j<=bot; j++) + idx.push_back({j,right}); + for (int j=right-1; j>=left; j--) + idx.push_back({bot,j}); + for (int j=bot-1; j>top; j--) + idx.push_back({j,left}); + + int idx_size = idx.size(); + for (int j=0; j order) { + int temp1[101][101]; + memcpy(temp1, A, sizeof(A)); + for (int idx : order) { + run_rotate(rotate_input[idx][0], rotate_input[idx][1], rotate_input[idx][2]); + } + get_min_val(); + memcpy(A, temp1, sizeof(A)); +} +int main() { + + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); + + cin >> N >> M >> C; + + for (int i=1; i<=N; i++) { + for (int j=1; j<=M; j++) { + cin >> A[i][j]; + } + } + + vector permute_vec(C); + for (int i=0; i> rotate_input[i][0]; + cin >> rotate_input[i][1]; + cin >> rotate_input[i][2]; + permute_vec[i] = i; + } + + do { + solve(permute_vec); + } while(next_permutation(permute_vec.begin(), permute_vec.end())); + + cout << ret; + return 0; +}