
1697 - 숨바꼭질 (BFS)
2022. 12. 12. 15:39
알고리즘(BOJ)/Silver
import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; //백준 public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int subin = sc.nextInt(); int dong = sc.nextInt(); int[] visited = new int[2000001]; Queue q = new LinkedList(); // 시작노드 q.offer(subin); int a = 0; while (!q.isEmpty()) { a = q.poll(); if (a == dong) { System.out.pri..