• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

求最长路,可以用最短路做,数组要开到1e6,否则会超时

#包括输入输出流

#包括队列

#包括字符串

使用命名空间标准

const int N=1e6 10

const int INF=0x 3 F3 F3 F3 f;

#首先定义x

#定义y秒

int ne[N],e[N],w[N],h[N],idx,in[N];

typedef pairint,int PII;

int n,m,dis[N];

布尔维斯[N];

void add(int a,int b,int c)

{

e[idx]=b,w[idx]=c,ne[idx]=h[a],h[a]=idx;

}

int Find_Max(int i)

{

memset(vis,0,sizeof vis);

memset(dis,-0x3f,sizeof dis);

queueint堆;

dis=0;

堆。推(一);

vis=1;

while(heap.size())

{

int t=堆。front();

堆。pop();

//int b=t.x,a=t.y

vis[t]=0;

for(int I=h[t];我!=-1;我=ne)

{

int j=e

if(dis[j] dis[t] w)

{

dis[j]=dis[t]w

if(vis[j]==0)

{

堆。push(j);

vis[j]=1;

}

}

}

}

int e=-INF;

for(int I=1;I=n;我)

e=max(e,dis);

返回e;

}

int main()

{

scanf('%d %d ',n,m);

int ans=-INF;

memset(h,-1,sizeof h);

while(m -)

{

int a,b,c;

scanf('%d %d %d ',a,b,c);

添加(甲、乙、丙);

中;

}

for(int I=1;I=n;我)

{

if(in==0)

{

ans=max(Find_Max(i),ans);

}

}

法院和法院

返回0;

}

Link to comment
Share on other sites