From 8c4c0658b8ea17c4d4652f43f4017d0904303baa Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Tue, 19 Aug 2025 20:26:21 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[20250819]=20B=ED=98=95=20/=20=EA=B2=BD?= =?UTF-8?q?=EC=9C=A0=EC=A7=80=EC=9A=B4=EC=86=A1=20/=20=EC=9D=B4=EA=B0=95?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...40\354\247\200\354\232\264\354\206\241.md" | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 "lkhyun/202508/19 B\355\230\225 \352\262\275\354\234\240\354\247\200\354\232\264\354\206\241.md" diff --git "a/lkhyun/202508/19 B\355\230\225 \352\262\275\354\234\240\354\247\200\354\232\264\354\206\241.md" "b/lkhyun/202508/19 B\355\230\225 \352\262\275\354\234\240\354\247\200\354\232\264\354\206\241.md" new file mode 100644 index 00000000..a6c97e06 --- /dev/null +++ "b/lkhyun/202508/19 B\355\230\225 \352\262\275\354\234\240\354\247\200\354\232\264\354\206\241.md" @@ -0,0 +1,75 @@ +```java +import java.util.*; +class UserSolution { + static class state implements Comparable{ + int to,w; + state(int to, int w){ + this.to = to; + this.w = w; + } + + @Override + public int compareTo(state other){ + return Integer.compare(other.w,this.w); + } + } + static List[] adjLists; + + public int[] dijkstra(int start){ + PriorityQueue pq = new PriorityQueue<>(); + int[] dist = new int[1000]; + for (int i = 0; i < dist.length; i++) { + dist[i] = -1; + } + for (state cur : adjLists[start]) { + pq.offer(new state(cur.to,cur.w)); + dist[cur.to] = cur.w; + } + + while(!pq.isEmpty()){ + state cur = pq.poll(); + + if(dist[cur.to] > cur.w) continue; + + for (state next : adjLists[cur.to]) { + int newDist = Math.min(cur.w,next.w); + if(newDist > dist[next.to]){ + dist[next.to] = newDist; + pq.offer(new state(next.to,newDist)); + } + } + } + return dist; + } + + public void init(int N, int K, int sCity[], int eCity[], int mLimit[]) { + adjLists = new ArrayList[N]; + for (int i = 0; i < N; i++) { + adjLists[i] = new ArrayList<>(); + } + for (int i = 0; i < K; i++) { + adjLists[sCity[i]].add(new state(eCity[i],mLimit[i])); + adjLists[eCity[i]].add(new state(sCity[i],mLimit[i])); + } + return; + } + + public void add(int sCity, int eCity, int mLimit) { + adjLists[sCity].add(new state(eCity,mLimit)); + adjLists[eCity].add(new state(sCity,mLimit)); + return; + } + + public int calculate(int sCity, int eCity, int M, int mStopover[]) { + int[] fromStart = dijkstra(sCity); + int ans = fromStart[eCity]; + for (int i = 0; i < M; i++) { + if(fromStart[mStopover[i]] == -1){ + return -1; + } + ans = Math.min(ans, fromStart[mStopover[i]]); + } + return ans; + } +} +``` From dacdc7e51bd4c1f69d640b287e4ced987ff8abc4 Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Tue, 19 Aug 2025 20:27:01 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Rename=2019=20B=ED=98=95=20=EA=B2=BD?= =?UTF-8?q?=EC=9C=A0=EC=A7=80=EC=9A=B4=EC=86=A1.md=20to=2019=20B=ED=98=95?= =?UTF-8?q?=20SWEA=20=EA=B2=BD=EC=9C=A0=EC=A7=80=EC=9A=B4=EC=86=A1.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...52\262\275\354\234\240\354\247\200\354\232\264\354\206\241.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "lkhyun/202508/19 B\355\230\225 \352\262\275\354\234\240\354\247\200\354\232\264\354\206\241.md" => "lkhyun/202508/19 B\355\230\225 SWEA \352\262\275\354\234\240\354\247\200\354\232\264\354\206\241.md" (100%) diff --git "a/lkhyun/202508/19 B\355\230\225 \352\262\275\354\234\240\354\247\200\354\232\264\354\206\241.md" "b/lkhyun/202508/19 B\355\230\225 SWEA \352\262\275\354\234\240\354\247\200\354\232\264\354\206\241.md" similarity index 100% rename from "lkhyun/202508/19 B\355\230\225 \352\262\275\354\234\240\354\247\200\354\232\264\354\206\241.md" rename to "lkhyun/202508/19 B\355\230\225 SWEA \352\262\275\354\234\240\354\247\200\354\232\264\354\206\241.md"