BZOJ 1726: [Usaco2006 Nov]Roadblocks第二短路 ——Dijkstra+玄学

这个题玄学冲过,规定每个点访问次数不能超过50次,然后找优先队列中第二次到达终点t的状态返回就ok

记录一下,怕忘了

#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
 
const int maxn=5010;
const int INF=0x3f3f3f3f;
struct HeapNode{
    int d,u;
    HeapNode(int _d,int _u):d(_d),u(_u){}
    bool operator <(const HeapNode &rhs)const{
        return d>rhs.d;
    }
};
struct Edge{
    int from,to;
    int w;
    Edge(int u,int v,int _w):from(u),to(v),w(_w){}
};
struct Dijkstra{
    vectoredges;
    vectorG[maxn];
    int vis[maxn];
    void add_edges(int u,int v,int cost){
        edges.push_back(Edge(u,v,cost));
        edges.push_back(Edge(v,u,cost));
        int m=edges.size();
        G[u].push_back(m-2);
        G[v].push_back(m-1);
    }
    int dij(int s,int t){
        memset(vis,0,sizeo

你可能感兴趣的:(瞎写,图论)