先放代码qwq
#warning By KonjAC_xrs
#warning ( testing == 0 ) ? Yes : No
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
inline ll read()
{
ll x=0,f=1; char ch=getchar();
while (!isdigit(ch)) {if(ch=='-') f=-1; ch=getchar();}
while ( isdigit(ch)) { x=x*10+ch-48; ch=getchar();}
return x*f;
}
void write(ll x)
{
if(x<0) putchar('-') , x=-x;
if(x>9) write(x/10);
putchar(x%10+'0');
}
//const ll inf=;
//const ll mod=;
const ll nore=200020;
ll tot1,ver1[nore<<1],nxt1[nore<<1],head1[nore],from1[nore];
double edge1[nore<<1];
inline void add1(ll x,ll y,double z)
{
ver1[++tot1]=y;
edge1[tot1]=z;
from1[tot1]=x;
nxt1[tot1]=head1[x];
head1[x]=tot1;
}
ll tot2,ver2[nore<<1],nxt2[nore<<1],head2[nore],from2[nore];
double edge2[nore<<1];
inline void add2(ll x,ll y,double z)
{
ver2[++tot2]=y;
from2[tot2]=x;
edge2[tot2]=z;
nxt2[tot2]=head2[x];
head2[x]=tot2;
}
ll n,m;
bool vis[nore];
double e,d[nore];
inline void spfa()
{
memset(d,0x3f,sizeof d);
d[n]=0;
priority_queue < pair < double , ll > > q;
q.push({0,n});
while(!q.empty())
{
ll x=q.top().second;
q.pop();
if(vis[x]) continue;
vis[x]=1;
for(register ll i=head2[x];i;i=nxt2[i])
{
ll y=ver2[i];
double z=edge2[i];
if(d[y]>d[x]+z)
{
d[y]=d[x]+z;
q.push({-d[y],y});
}
}
}
}
inline ll Astar()
{
ll res=0;
priority_queue < pair < double , pair < double , ll > > > q;
q.push({-d[1],{0,1}});
while(!q.empty())
{
ll x=q.top().second.second;
double dis=q.top().second.first;
q.pop();
if(x==n)
{
if(e<dis)
return res;
++res;
e-=dis;
}
for(register ll i=head1[x];i;i=nxt1[i])
{
ll y=ver1[i]; double z=edge1[i];
if(dis+z+d[y]<=e)
q.push({-(dis+z+d[y]),{(dis+z),y}});
}
}
return res;
}
int main()
{
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
n=read(); m=read(); cin>>e;
for(register ll i=1,x,y;i<=m;i++)
{
x=read(); y=read();
double z; cin>>z;
add1(x,y,z); add2(y,x,z);
}
spfa();
write(Astar()); puts("");
getchar();
return 0;
}
37分,其他的都MLE,各位dalao有没有什么好的优化方法 

