#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N,M,K; int S,T; int X[202020],Y[202020]; bitset<2020> B[2020]; vector E[202020]; double D[2020]; vector P[2020]; double dist[2020][2020]; pair> hoge(int start,set> NG,vector pref,double prel) { int i; FOR(i,N) D[i]=1e9, P[i].clear(), B[i].reset(); FORR(p,pref) D[p]=-1; D[start]=prel; P[start]=pref; P[start].push_back(start); FORR(p,pref) B[start][p]=1; priority_queue> Q; Q.push({-prel,start}); while(Q.size()) { double co=-Q.top().first; int cur=Q.top().second; Q.pop(); if(D[cur]!=co) continue; FORR(e,E[cur]) { if(NG.count({e,cur})) continue; if(NG.count({cur,e})) continue; if(B[cur][e]) continue; double d=co+dist[cur][e]; if(D[e]>d) { D[e]=d; P[e]=P[cur]; P[e].push_back(e); B[e]=B[cur]; B[e][e]=1; Q.push({-d,e}); } } } return {D[T],P[T]}; } void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>M>>K>>S>>T; S--,T--; FOR(i,N) cin>>X[i]>>Y[i]; FOR(x,N) FOR(y,N) dist[x][y]=hypot(X[x]-X[y],Y[x]-Y[y]); FOR(i,M) { cin>>x>>y; E[x-1].push_back(y-1); E[y-1].push_back(x-1); } vector>> ret; vector>> cand; set> NG; ret.push_back(hoge(S,NG,vector(),0)); while(ret.size() pre; FOR(x,ret.back().second.size()-1) { if(x) { pre.push_back(ret.back().second[x-1]); sum+=dist[ret.back().second[x-1]][ret.back().second[x]]; } NG.clear(); FOR(i,ret.size()) { if(ret[i].second.size()1e8) break; ret.push_back(cand[0]); cand.erase(cand.begin()); } FOR(i,K) { if(i