diff options
author | Santo Cariotti <sancn@live.com> | 2017-04-26 16:37:39 +0200 |
---|---|---|
committer | Santo Cariotti <sancn@live.com> | 2017-04-26 16:37:39 +0200 |
commit | 483d63fa7249ad8d6020680c48c3cf6df35010b3 (patch) | |
tree | 2f8649e3ae6b42ace5011246285c9c450f004222 /cpp/Es5.cpp | |
parent | 6c957dc4e01aee6ce9cae3c8342d04b0fd9ca9c4 (diff) |
Moved all C++ files into CPP folder
Diffstat (limited to 'cpp/Es5.cpp')
-rw-r--r-- | cpp/Es5.cpp | 46 |
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;
+}
|