学习了大佬题解。根据大佬的讲解,把对应部分分的代码打到一起了。(有点臃肿)
#pragma GCC optimize(2)
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
const int N=1e5+10,M=2e5+10;
#define re register
int tot,t,n,m,k,p,hd[N],vis[N],hdn[N],totn,id[N],idx[N];
int cnt[N],f[N][55],ans,deg[N],hd0[N],tot0,q[N];
ll dis[N],disn[N];
inline int read()
{
int s=0,f=1;char ch=getchar();
while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+(ch^48),ch=getchar();
return s*f;
}
struct Edge{
int v,nx;ll w;
}e[M],en[M];
struct node{
int u;ll w;
node(){}
node(int _u,ll _w):u(_u),w(_w){}
bool operator <(const node&rhs)const{
return w>rhs.w;}
};
namespace pts30{
void add(int u,int v,ll w)
{
e[tot].v=v;
e[tot].nx=hd[u];
e[tot].w=w;
hd[u]=tot++;
}
void dijkstra()
{
memset(dis,0x7f,size