Skip to content

Conversation

@jinan159
Copy link
Contributor

시간복잡도

시간 R, 가로 M, 세로 N

O(RMN)

접근과정

image
image

위 그림처럼, 각 방향을 색으로 칠해보니 규칙성이 보였습니다.
그래서 좌표 평면에서 각 방향별 공식을 구하고 이를 이용하여 여러번 회전하도록 구현하였습니다.

private static boolean isDown(double midM, int y, int x) {
    return x < (int) midM && x <= y && y < N - (x + 1);
}

private static boolean isUp(double midM, int y, int x) {
    return x >= midM && y >= (M - x) && y <= N - (M - x);
}

private static boolean isLeft(double midN, int y, int x) {
    return y < midN && x > y && x < (M - y);
}

private static boolean isRight(double midN, int y, int x) {
    return y >= midN && x >= N - (y + 1) && x < M - (N - y);
}

삽질

공식을 구하기까지 너무 삽질을 많이 했습니다.
엣지 케이스를 모두 만족하는 수식을 구하기 위해 여러번 수식을 고치면서 삽질을 했습니다.

@jinan159 jinan159 added the BOJ label May 15, 2022
@jinan159 jinan159 linked an issue May 15, 2022 that may be closed by this pull request
@jinan159 jinan159 changed the title 문제 풀이 추가 [Jay] BOJ(16926): 배열 돌리기 - 문제풀이 May 15, 2022
@jinan159 jinan159 self-assigned this May 15, 2022
@rxdcxdrnine rxdcxdrnine merged commit 000cb64 into CodeSquad-Algorithm:main May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2022.05.10(화)] BOJ(16926) : 배열 돌리기 1

2 participants