We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package main.java.com.poogle.BOJ.Q5014; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { static int f, s, g, u, d; static int[] visited; public static void main(String[] args) { Scanner sc = new Scanner(System.in); f = sc.nextInt(); //최고층 s = sc.nextInt(); //현재 위치 g = sc.nextInt(); //도착지 u = sc.nextInt(); //위 d = sc.nextInt(); //아래 visited = new int[f + 1]; bfs(f, s, g, u, d); } private static void bfs(int f, int s, int g, int u, int d) { Queue<Integer> queue = new LinkedList<>(); queue.offer(s); visited[s] = 1; while (!queue.isEmpty()) { int now = queue.poll(); if (now == g) { System.out.println(visited[now] - 1); } if (now + u <= f && visited[now + u] == 0) { visited[now + u] = visited[now] + 1; queue.offer(now + u); } if (now - d > 0 && visited[now - d] == 0) { visited[now - d] = visited[now] + 1; queue.offer(now - d); } } if (visited[g] == 0) System.out.println("use the stairs"); } }
The text was updated successfully, but these errors were encountered:
97aecb4
suhyunsim
No branches or pull requests
문제
핵심 아이디어
어려운 점, 실수
풀이
The text was updated successfully, but these errors were encountered: