diff --git "a/6\354\243\274\354\260\250-\352\267\270\353\236\230\355\224\204/w06-Kaya/BOJ1504.java" "b/6\354\243\274\354\260\250-\352\267\270\353\236\230\355\224\204/w06-Kaya/BOJ1504.java" new file mode 100644 index 0000000..06963d3 --- /dev/null +++ "b/6\354\243\274\354\260\250-\352\267\270\353\236\230\355\224\204/w06-Kaya/BOJ1504.java" @@ -0,0 +1,92 @@ +import java.util.*; +import java.io.*; + +class Node implements Comparable { + int vertex, weight; + + public Node(int vertex, int weight) { + this.vertex = vertex; + this.weight = weight; + } + @Override + public int compareTo(Node o){ + return weight - o.weight; + } +} +public class Main { + static int v, e, v1, v2; + static ArrayList[] list; + static int[] dist; + static boolean[] check; + static final int INF = 200000000; + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + v = Integer.parseInt(st.nextToken()); + e = Integer.parseInt(st.nextToken()); + + list = new ArrayList[v+1]; + for(int i=0; i(); + } + dist = new int[v+1]; + check = new boolean[v+1]; + + for(int i=0; i= INF && result2 >= INF) { + ans = -1; + } else { + ans = Math.min(result1, result2); + } + + System.out.println(ans); + } + + public static int dijkstra(int start, int end) { + Arrays.fill(dist, INF); + Arrays.fill(check, false); + + PriorityQueue q = new PriorityQueue<>(); + q.add(new Node(start, 0)); + dist[start] = 0; + + while(!q.isEmpty()) { + Node curr = q.poll(); + int currNode = curr.vertex; + int currWeight = curr.weight; + + if(check[currNode]) continue; + check[currNode] = true; + + for(int i=0; i currWeight + nextWeight) { + dist[nextNode] = currWeight + nextWeight; + q.add(new Node(nextNode, dist[nextNode])); + } + } + } + return dist[end]; + } +} diff --git "a/6\354\243\274\354\260\250-\352\267\270\353\236\230\355\224\204/w06-Kaya/\354\210\234\354\234\204.java" "b/6\354\243\274\354\260\250-\352\267\270\353\236\230\355\224\204/w06-Kaya/\354\210\234\354\234\204.java" new file mode 100644 index 0000000..0cd0afa --- /dev/null +++ "b/6\354\243\274\354\260\250-\352\267\270\353\236\230\355\224\204/w06-Kaya/\354\210\234\354\234\204.java" @@ -0,0 +1,32 @@ +class Solution { + public int solution(int n, int[][] results) { + int answer = 0; + int[][] game = new int[n+1][n+1]; + + for(int i=0; i