1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| #include <iostream> #include <cstdio> #include <cstring> using namespace std; #define Inf 2e31-1 #define DEBUG(x) std::cerr << #x << '=' << x << endl; #define MAXN 2500 + 5
struct Node; struct Edge; struct Node{ Edge *firstEdge; int dist; bool inQueue; } node[MAXN];
struct Edge{ Node *s,*t; int w; Edge *next;
Edge(Node *s,Node *t,int w) : s(s),t(t),w(w),next(s->firstEdge); }; inline void add(const int &s,const int &t,const int &w){ node[s].firstEdge = new Edge(&node[s],&node[t],w); node[t].firstEdge = new Edge(&node[t],&node[s],w); }
int main(int argc, char const *argv[]) { int n,m,s,t; ios::sync_with_stdio(false); cin >> n >> m >> s >> t; for (int i = 1;i <= m;i++){ int u,v,w; cin >> u,v,w; add(u,v,w); } return 0; }
|