Problem Statement
Flight Routes
Implementation
void solve() {
ll n, m, k;
cin >> n >> m >> k;
vector <vpll> v(n);
rep(i, m) {
ll x, y, w;
cin >> x >> y >> w;
--x, --y;
v[x].pb({ y, w });
}
vvll use(n);
function <void(ll)> dij = [&](ll node) {
multiset<pll> st;
st.insert({ 0, node });
while (sz(st)) {
auto cur = *st.begin();
st.erase(st.begin());
if (sz(use[cur.s]) >= k) continue;
use[cur.s].pb(cur.f);
for (auto& child : v[cur.s])
st.insert({ cur.f + child.s, child.f });
}
};
dij(0);
rep(i, k) cout << use[n - 1][i] << " ";
cout << "\n";
}