# LOJ6354 & 洛谷4366：[Code+#4]最短路——题解

https://loj.ac/problem/6354

https://www.luogu.org/problemnew/show/P4366

```#include<cmath>
#include<queue>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef pair<int,int>pii;
#define fi first
#define se second
const int N=1e5+5;
const int M=5e5+5;
int X=0,w=0;char ch=0;
while(!isdigit(ch)){w|=ch==‘-‘;ch=getchar();}
while(isdigit(ch))X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
return w?-X:X;
}
struct node{
int to,nxt,w;
}e[M+N*20];
inline void add(int u,int v,int w){
}
int dis[N];
priority_queue<pii,vector<pii>,greater<pii> >q;
void dij(int s){
memset(dis,127,sizeof(dis));
dis[s]=0;q.push(pii(0,s));
while(!q.empty()){
int u=q.top().se,f=q.top().fi;q.pop();
if(f!=dis[u])continue;
int v=e[i].to,w=e[i].w;
if(dis[v]>dis[u]+w){
dis[v]=dis[u]+w;
q.push(pii(dis[v],v));
}
}
}
return;
}
int main(){
for(int i=1;i<=m;i++){
}
for(int u=0;u<=n;u++){
for(int i=1;i<=n;i<<=1){
int v=u^i;if(v>n)continue;
}
}
dij(s);
printf("%d\n",dis[t]);
return 0;
}```

+++++++++++++++++++++++++++++++++++++++++++

+本文作者：luyouqi233。 　　　　　　　　　　　　　　+

+欢迎访问我的博客：http://www.cnblogs.com/luyouqi233/ +

+++++++++++++++++++++++++++++++++++++++++++

LOJ6354 & 洛谷4366：[Code+#4]最短路——题解

(0)
(0)

0条