From f31ffce7615e6199b89e8fd05d7a0e5d50228921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=EC=9C=A0=ED=99=98?= Date: Fri, 10 Oct 2025 06:09:26 +0900 Subject: [PATCH 1/2] =?UTF-8?q?1854=EB=B2=88=20=ED=92=80=EC=9D=B4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 0x1D/solutions/1854.cpp | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/0x1D/solutions/1854.cpp b/0x1D/solutions/1854.cpp index 6c991660..22aa5b35 100644 --- a/0x1D/solutions/1854.cpp +++ b/0x1D/solutions/1854.cpp @@ -1,11 +1,36 @@ -// Authored by : BaaaaaaaaaaarkingDog +// Authored by : uhwan0723 // Co-authored by : - -// http://boj.kr/**************** +// http://boj.kr/b65501cb42b24247997604ce3d94be7c #include using namespace std; +const int mn = 1e4+5, md = 1e7+5; +int n, m, k; +vector d[mn]; +vector> adj[mn]; +priority_queue> pq; + int main(void){ ios::sync_with_stdio(0); cin.tie(0); - -} \ No newline at end of file + cout.tie(0); + cin >> n >> m >> k; + while(m--){ + int u, v, w; + cin >> u >> v >> w; + adj[u].push_back({w, v}); + } + pq.push({0, 1}); + while(!pq.empty()){ + int w = -pq.top().first, cur = pq.top().second; + pq.pop(); + if(d[cur].size() == k) continue; + d[cur].push_back(w); + for(auto nxt : adj[cur]) + pq.push({-(w + nxt.first), nxt.second}); + } + for(int i = 1; i <= n; ++i){ + if(d[i].size() < k) cout << -1 << '\n'; + else cout << d[i][k-1] << '\n'; + } +} From d5675ba83db9e7dc80ef6f25ff58c08652ec0855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=EC=9C=A0=ED=99=98?= Date: Fri, 10 Oct 2025 06:12:51 +0900 Subject: [PATCH 2/2] delete unused constant --- 0x1D/solutions/1854.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/0x1D/solutions/1854.cpp b/0x1D/solutions/1854.cpp index 22aa5b35..8b066843 100644 --- a/0x1D/solutions/1854.cpp +++ b/0x1D/solutions/1854.cpp @@ -1,10 +1,10 @@ // Authored by : uhwan0723 // Co-authored by : - -// http://boj.kr/b65501cb42b24247997604ce3d94be7c +// http://boj.kr/2e7aad928479422d845f500c2c77609b #include using namespace std; -const int mn = 1e4+5, md = 1e7+5; +const int mn = 1e4+5; int n, m, k; vector d[mn]; vector> adj[mn];