保留的一定是所有最短路树上的边
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef pair<LL, int> PII;
const int N = 1e5 + 10,M = 2e5 + 10;
int n,m,k;
int h[N], e[M], w[M], ne[M], idx,id[M];
LL dist[N];
bool st[N];
vector<int> ans;
void add(int a, int b, int c,int d) // 添加一条边a->b,边权为c
{
e[idx] = b, w[idx] = c, id[idx] = d ,ne[idx] = h[a], h[a] = idx ++ ;
}
void dijkstra() // 求1号点到n号点的最短路距离
{
memset(dist, 0x3f, sizeof dist);
dist[1] = 0;
priority_queue<PII, vector<PII>, greater<PII>> heap;
heap.push({0, 1});
while (heap.size())
{
auto t = heap.top();
heap.pop();
int ver = t.second, distance = t.first;
if (st[ver]) continue;
st[ver] = true;
for (int i = h[ver]; i != -1; i = ne[i])
{
int j = e[i];
if (dist[j] > dist[ver] + w[i])
{
dist[j] = dist[ver] + w[i];
heap.push({dist[j], j});
}
}
}
}
void dfs(int u){
st[u] = true;
for(int i=h[u];~i;i=ne[i]){
int j = e[i];
if(!st[j] && dist[j] == dist[u] + w[i]){
if(ans.size() < k) ans.push_back(id[i]);
dfs(j);
}
}
}
int main()
{
scanf("%d %d %d",&n,&m,&k);
memset(h, -1, sizeof h);
for(int i=1;i<=m;i++){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
add(a, b, c ,i);
add(b, a, c ,i);
}
dijkstra();
memset(st, 0, sizeof st);
dfs(1);
printf("%d\n",ans.size());
for(auto a:ans) printf("%d ",a);
return 0;
}