#include using namespace std; using ll=long long int; //using Int=__int128; #define ALL(A) A.begin(),A.end() template bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;} template bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;} template constexpr int bitUP(T x,int a){return (x>>a)&1;} template struct edge { int to; T cost; edge()=default; edge(int to, T cost) : to(to), cost(cost) {} }; template using WeightGraph=vector>>; //https://qiita.com/nariaki3551/items/821dc6ffdc552d3d5f22 //https://yamakuramun.info/2021/02/24/309/ template vector>> YenAlgorithm(const WeightGraph &graph,int k,int s,int t){ assert(k>=1); int N=graph.size(); const auto max_inf = numeric_limits< T >::max(); const auto min_inf = numeric_limits< T >::lowest(); assert(0<=s and s>; map,unordered_set> ban_edge; //Pを返す auto dijkstra=[&](const vector &spur_path){ using pti=pair; vector dist(N,pti(max_inf,-1)); for(int v:spur_path){ dist[v].first=min_inf; } priority_queue,greater> que; int start=s; if(spur_path.size()) start=spur_path.back(); dist[start].first=0; auto &ban=ban_edge[spur_path]; que.emplace(0,start); while(!que.empty()){ T cost; int v; tie(cost,v)=que.top(); if(v==t) break; que.pop(); if(dist[v].first path; if(dist[t].first==max_inf){ return P(dist[t].first,path); } int now=t; while(now!=start){ path.push_back(now); now=dist[now].second; } //reverse(path.begin(),path.end()); return P(dist[t].first,path); }; vector

ans; auto compare=[](P a,P b){ return a.first>b.first; }; priority_queue,decltype(compare)> candidate(compare); vector prev_path; vector spur_path; set> set_ans; while(k--){ if(ans.size()==0){ auto c=dijkstra(spur_path); c.second.push_back(s); reverse(c.second.begin(),c.second.end()); if(c.first!=max_inf) candidate.push(c); }else{ T prev_cost=0; for(int i=0;i=0;j--) c.second.push_back(prev_path[j]); reverse(c.second.begin(),c.second.end()); c.first+=prev_cost; if(c.first!=max_inf) candidate.push(c); for(auto &e:graph[prev_path[i]]){ if(e.to==prev_path[i+1]) prev_cost+=e.cost; } } } bool ok=false; while(candidate.size()){ auto c=candidate.top(); candidate.pop(); if(set_ans.count(c.second)) continue; ans.push_back(c); prev_path=c.second; ok=true; set_ans.insert(c.second); break; } if(not ok) break; spur_path.clear(); } return ans; } void solve(){ int N,M,K; cin>>N>>M>>K; int s,t; cin>>s>>t; s--; t--; WeightGraph graph(N); vector p(N),q(N); for(int i=0;i>p[i]>>q[i]; } for(int i=0;i>a>>b; a--; b--; double dp=p[a]-p[b],dq=q[a]-q[b]; double cost=sqrt(dp*dp+dq*dq); graph[a].emplace_back(b,cost); graph[b].emplace_back(a,cost); } auto ans=YenAlgorithm(graph,K,s,t); for(int i=0;i=int(ans.size())){ cout<<-1<