//GNC #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef int point; typedef int weight; struct edge{ point dest; weight w; edge(){} edge(const point &dest, const weight &w):dest(dest),w(w){} }; bool operator>(const edge&lhs, const edge&rhs) { return lhs.w > rhs.w; } typedef vector edges; typedef map graph; typedef map potential; potential dijkstra(graph &g, point p) { potential pot; priority_queue > toBeProcessed; toBeProcessed.push(edge(p,0)); while ( !toBeProcessed.empty()) { edge top=toBeProcessed.top(); point p=top.dest; weight curr=top.w; toBeProcessed.pop(); if ( pot.count(p)!=0 ) continue; pot[p]=curr; edges& es=g[p]; for ( int i=0 ; i> Ncities >> Medges >> Kcapacity && Ncities){ if(!first) cout << endl; first = false; graph nor; graph inv; vector es; int from, to, w; for(int i = 0; i < Medges; ++i){ cin >> from >> to >> w; nor[from].push_back(edge(to, w)); inv[to].push_back(edge(from, w)); es.push_back(edgepos(from, to, w)); } potential ordpot = dijkstra(nor, 1); potential invpot = dijkstra(inv, Ncities); int best = ordpot[Ncities]; vector results; for(int i = 0; i < Medges; ++i){ int f = es[i].from, t = es[i].to; if(ordpot.count(f) && invpot.count(t) && ordpot[f] + invpot[t] + es[i].w <= best + Kcapacity){ results.push_back(i+1); } } cout << results.size() << endl; for(int i = 0; i < results.size(); ++i){ cout << results[i] << endl; } } return 0; }