//Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and 
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
// same ids are connected.
// prefix 的格式要求是 acm-[一级标题编号].[二级标题编号][该代码片段的英文简称]
// description 的格式要求是 "插入 [该代码片段的中文名]"

{
    "最短路": {
        "prefix": "acm-3.1dijkstra",
        "body": [
            "#include<cstring>",
            "#include<cstdio>",
            "#include<queue>",
            "#define Re register int",
            "using namespace std;",
            "const int N=1e5+5,M=1e5+5,inf=2e9;",
            "int x,y,z,n,m,o,to,st,dis[N],pan[N],head[N];",
            "struct QAQ{int w,to,next;}a[M<<1];",
            "struct QWQ{int x,d;inline bool operator<(QWQ O)const{return d>O.d;}};",
            "priority_queue<QWQ>Q;",
            "inline void in(Re &x){",
            "\tRe fu=0;x=0;char ch=getchar();",
            "\twhile(ch<'0'||ch>'9')fu|=ch=='-',ch=getchar();",
            "\twhile(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();",
            "\tx=fu?-x:x;",
            "}",
            "inline void add(Re x,Re y,Re z){a[++o].to=y,a[o].w=z,a[o].next=head[x],head[x]=o;}",
            "inline void dijkstra(Re st){",
            "\tfor(Re i=0;i<=n;++i)dis[i]=inf;",
            "\tdis[st]=0,Q.push((QWQ){st,0});",
            "\twhile(!Q.empty()){",
            "\t\tx=Q.top().x,Q.pop();",
            "\t\tif(pan[x])continue;",
            "\t\tpan[x]=1;",
            "\t\tfor(Re i=head[x];i;i=a[i].next)",
            "\t\t\tif(dis[to=a[i].to]>dis[x]+a[i].w){",
            "\t\t\t\tdis[to]=dis[x]+a[i].w;",
            "\t\t\t\tQ.push((QWQ){to,dis[to]});",
            "\t\t\t}",
            "\t}",
            "}",
            "int main(){",
            "\tin(n),in(m),in(st);",
            "\twhile(m--)in(x),in(y),in(z),add(x,y,z);",
            "\tdijkstra(st);",
            "\tfor(Re i=1;i<=n;++i)printf(\"%d \",dis[i]);",
            "}",
            ""
        ],
        "description": "插入 最短路"
    }
}