跳到正文

剪贴板

剪贴板 s1b8mn7f

原文
剪贴板信息

剪贴板信息

收录
更新
C++
#include <iostream>
using namespace std;
template<typename T=int>
inline T read(){
    T X=0; bool flag=1; char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-') flag=0; ch=getchar();}
    while(ch>='0' && ch<='9') X=(X<<1)+(X<<3)+ch-'0',ch=getchar();
    if(flag) return X;
    return ~(X-1);
}

template<typename T=int>
inline void write(T X){
    if(X<0) putchar('-'),X=~(X-1);
    T s[20],top=0;
    while(X) s[++top]=X%10,X/=10;
    if(!top) s[++top]=0;
    while(top) putchar(s[top--]+'0');
    putchar('\n');
}

const int N=1e6+5,M=2e6+5,inf=0x3f3f3f3f;
struct edge{
    int to,nxt,val;
}e[M];
int n,m,s,u,v,w;
int head[N],top;

void add(int u,int v,int w){
    top++;
    e[top].to=v;
    e[top].val=w;
    e[top].nxt=head[u];
    head[u]=top;
}

int main(){
    n=read(),m=read(),s=read();
    while(m--){
        u=read(),v=read(),w=read();
        add(u,v,w);
        // add(v,u,w);
    }

    return 0;
}