diff --git "a/JHLEE325/202602/03 BOJ G5 \353\236\255\355\215\274\353\223\240 \354\210\230\354\227\264\354\237\201\354\235\264\354\225\274!!.md" "b/JHLEE325/202602/03 BOJ G5 \353\236\255\355\215\274\353\223\240 \354\210\230\354\227\264\354\237\201\354\235\264\354\225\274!!.md" new file mode 100644 index 00000000..2faa47c7 --- /dev/null +++ "b/JHLEE325/202602/03 BOJ G5 \353\236\255\355\215\274\353\223\240 \354\210\230\354\227\264\354\237\201\354\235\264\354\225\274!!.md" @@ -0,0 +1,57 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + + static int n, x, y, count; + static int[] arr; + static boolean[] used; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + n = Integer.parseInt(st.nextToken()); + x = Integer.parseInt(st.nextToken()); + y = Integer.parseInt(st.nextToken()); + + arr = new int[2 * n + 1]; + used = new boolean[n + 1]; + + int fixedNum = y - x - 1; + arr[x] = arr[y] = fixedNum; + used[fixedNum] = true; + + check(1); + + System.out.println(count); + } + + static void check(int pos) { + if (pos == 2 * n + 1) { + count++; + return; + } + + if (arr[pos] != 0) { + check(pos + 1); + return; + } + + for (int i = 1; i <= n; i++) { + if (used[i]) continue; + + if (pos + i + 1 <= 2 * n && arr[pos + i + 1] == 0) { + arr[pos] = arr[pos + i + 1] = i; + used[i] = true; + + check(pos + 1); + + arr[pos] = arr[pos + i + 1] = 0; + used[i] = false; + } + } + } +} +```