diff --git "a/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-1033] \354\271\265\355\205\214\354\235\274.md" "b/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-1033] \354\271\265\355\205\214\354\235\274.md" new file mode 100644 index 0000000..4b78fe4 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-1033] \354\271\265\355\205\214\354\235\274.md" @@ -0,0 +1,139 @@ +```java +import java.math.BigInteger; +import java.util.*; +import java.io.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController() { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + String nextToken() throws Exception { + while (!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +public class Main { + + static IOController io; + + // + + static int N; + static long[] A; + static List[] V; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + init(); + solve(); + + io.close(); + + } + + public static void init() throws Exception { + + N = io.nextInt(); + V = new List[N]; + for(int i=0;i(); + for(int i=1;i A; + + static List[] V; + static int[] C, deg, ans, dist; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + init(); + solve(); + + io.close(); + + } + + public static void init() throws Exception { + + N = io.nextInt(); + A = new ArrayList<>(); + for(int i=0;i list) { + + deg = new int[N]; + V = new List[N]; + for(int i=0;i(); + + int n = list.size(); + Stack stack = new Stack<>(); + for(int i=0;i stack.peek()[0]) { + int index = stack.pop()[1]; + V[x].add(index); + deg[index]++; + } + stack.push(new int[]{h, x}); + } + + } + + static void dfs(int n, int p, int d) { + C[n] += d; + if(p != -1) { + if(ans[n] == -1) { + ans[n] = p+1; + dist[n] = Math.abs(p-n); + } + else { + if(dist[n] >= Math.abs(p-n)) { + ans[n] = p+1; + dist[n] = Math.abs(p-n); + } + } + } + + for(int i:V[n]) dfs(i,n,d+1); + } + +} +``` diff --git "a/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-24337] \352\260\200\355\235\254\354\231\200 \355\203\221.md" "b/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-24337] \352\260\200\355\235\254\354\231\200 \355\203\221.md" new file mode 100644 index 0000000..4305cd8 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_21\354\243\274\354\260\250/[BOJ-24337] \352\260\200\355\235\254\354\231\200 \355\203\221.md" @@ -0,0 +1,113 @@ +```java +import java.math.BigInteger; +import java.util.*; +import java.io.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController() { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + String nextToken() throws Exception { + while (!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +public class Main { + + static IOController io; + + // + + static int N, A, B; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + init(); + solve(); + + io.close(); + + } + + public static void init() throws Exception { + + N = io.nextInt(); + A = io.nextInt(); + B = io.nextInt(); + + } + + static void solve() throws Exception { + + if(A + B > N+1) { + io.write("-1\n"); + return; + } + int[] ans = new int[N]; + if(A == 1) { + ans[0] = B; + int temp = 1; + for(int i=N-1,k=1;k++mid;i--) ans[i] = temp++; + temp = 1; + for(int i=mid-A+1;i