summaryrefslogtreecommitdiff
path: root/cpp/Es5.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/Es5.cpp')
-rw-r--r--cpp/Es5.cpp46
1 files changed, 46 insertions, 0 deletions
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 <iostream>
+#define BIANCO 0 //Non Visitato
+#define NERO 2 //Visitato
+#define GRIGIO 1 //Non Finito
+#define INF 999999
+#include <vector>
+#include <fstream>
+#include <queue>
+#define MAXN 9999
+#define INDEF -1
+#include <stack>
+using namespace std;
+typedef pair <int,int> p;
+struct nodo{
+ vector<int> adj;
+ vector<int> p;
+};
+
+int main(int argc, char** argv) {
+ int v,e;
+ int sorgente;
+ nodo no[v];
+
+ priority_queue<p> Q;
+ int peso[v];
+ Q.push(p(0,sorgente));
+
+ while(!Q.empty())
+ {
+ pair <int,int> a=Q.top();
+ Q.pop();
+ if (a.first > peso[a.second])
+ continue;
+
+ for (int i=0;i<no[a.second].adj.size();i++)
+ {
+ if (peso[no[a.second].adj[i]]>a.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;
+}