#include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int maxn = 2e5 + 10; vector > graph[maxn]; struct node { int idx; ll cost; node() {} node(int _idx, ll _cost) { idx = _idx; cost = _cost; } bool operator < (const node & tmp) const { return cost > tmp.cost; } }; int main() { ios_base::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; for(int i = 0; i < m; i++) { int a, b, c; cin >> a >> b >> c; a--; b--; graph[a].push_back(make_pair(b, c)); } priority_queue pq; pq.push(node(0, 0)); vector visited(n + 1, 0); int E = n - 1; while(!pq.empty() and visited[E] < k) { node c = pq.top(); pq.pop(); visited[c.idx]++; if(c.idx == E) { cout << c.cost << " "; } if(visited[c.idx] <= k) { for(int i = 0; i < (int) graph[c.idx].size(); i++) { int neighbour = graph[c.idx][i].first; ll weight = graph[c.idx][i].second; pq.push(node(neighbour, c.cost + weight)); } } } return 0; }