#include#include #include using namespace std;const int M=999999;int n,m,f[M],flag;int vis[M],d[M],dis[M];int nex[M],tot,to[M],head[M],cos[M];void add(int x,int y,int z){ nex[++tot]=head[x]; to[tot]=y; cos[tot]=z; head[x]=tot;}void spfa(int s){ d[1]=s; vis[s]=1; memset(dis,128,sizeof(dis)); dis[s]=0; int h=0,t=1; do{ h++; int x=d[h]; vis[x]=0; for(int i=head[x];i;i=nex[i]) { int tmp=to[i]; if(dis[tmp] n) { printf("NO"); flag=1; return; } } } } } while(h
全弄成>=,跑最长路