From a51d9705636a325d7dcf9a3ebfac259fbbd259d9 Mon Sep 17 00:00:00 2001 From: oncsr Date: Wed, 19 Mar 2025 15:57:53 +0900 Subject: [PATCH] =?UTF-8?q?[20250319]=20BOJ=20/=20G5=20/=20=EB=B9=84?= =?UTF-8?q?=ED=8A=B8=20=EB=AC=B8=EC=9E=90=EC=97=B4=20=EC=9E=AC=EB=B0=B0?= =?UTF-8?q?=EC=97=B4=ED=95=98=EA=B8=B0=20/=20=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...60\354\227\264\355\225\230\352\270\260.md" | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 "khj20006/202503/19 BOJ G5 \353\271\204\355\212\270 \353\254\270\354\236\220\354\227\264 \354\236\254\353\260\260\354\227\264\355\225\230\352\270\260.md" diff --git "a/khj20006/202503/19 BOJ G5 \353\271\204\355\212\270 \353\254\270\354\236\220\354\227\264 \354\236\254\353\260\260\354\227\264\355\225\230\352\270\260.md" "b/khj20006/202503/19 BOJ G5 \353\271\204\355\212\270 \353\254\270\354\236\220\354\227\264 \354\236\254\353\260\260\354\227\264\355\225\230\352\270\260.md" new file mode 100644 index 00000000..1b072c30 --- /dev/null +++ "b/khj20006/202503/19 BOJ G5 \353\271\204\355\212\270 \353\254\270\354\236\220\354\227\264 \354\236\254\353\260\260\354\227\264\355\225\230\352\270\260.md" @@ -0,0 +1,87 @@ +```java + +import java.util.*; +import java.io.*; + +class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + if(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int N, M; + static int start = 0, end1 = 0, end2 = 0; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + M = nextInt(); + for(int i=N-1;i>=0;i--) if(nextInt() == 1) start |= (1<=0;i--) { + if(i%2 == 0) { + x += temp[i]; + for(int j=0;j Q = new LinkedList<>(); + Q.offer(new int[] {start,0}); + while(!Q.isEmpty()) { + int[] now = Q.poll(); + int n = now[0], t = now[1]; + if(n == end1 || n == end2) { + bw.write(t+"\n"); + return; + } + for(int i=0;i>1); + if(!vis[next]) { + vis[next] = true; + Q.offer(new int[] {next,t+1}); + } + } + } + + } + +} + +```