From 483d63fa7249ad8d6020680c48c3cf6df35010b3 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 26 Apr 2017 16:37:39 +0200 Subject: Moved all C++ files into CPP folder --- cpp/Es5.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 cpp/Es5.cpp (limited to 'cpp/Es5.cpp') diff --git a/cpp/Es5.cpp b/cpp/Es5.cpp new file mode 100644 index 0000000..8f6fb48 --- /dev/null +++ b/cpp/Es5.cpp @@ -0,0 +1,46 @@ +#include +#define BIANCO 0 //Non Visitato +#define NERO 2 //Visitato +#define GRIGIO 1 //Non Finito +#define INF 999999 +#include +#include +#include +#define MAXN 9999 +#define INDEF -1 +#include +using namespace std; +typedef pair p; +struct nodo{ + vector adj; + vector p; +}; + +int main(int argc, char** argv) { + int v,e; + int sorgente; + nodo no[v]; + + priority_queue

Q; + int peso[v]; + Q.push(p(0,sorgente)); + + while(!Q.empty()) + { + pair a=Q.top(); + Q.pop(); + if (a.first > peso[a.second]) + continue; + + for (int i=0;ia.first+ no[a.second].p[i]) + { + peso[no[a.second].adj[i]]=a.first + no[a.second].p[i]; + Q.push(p(peso[no[a.second].adj[i]],no[a.second].adj[i])); + } + } + + } + return 0; +} -- cgit v1.2.3-18-g5258