We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 851eddf commit 094baf3Copy full SHA for 094baf3
Dijkstra(Heap-Optimised).cpp
@@ -2,8 +2,8 @@
2
3
#define INF 1000000000
4
5
-#define VERTEX_COUNT 100000
6
-#define EDGE_COUNT 100000
+#define VERTEX_COUNT 100010
+#define EDGE_COUNT 1000010
7
8
using namespace std;
9
@@ -86,20 +86,23 @@ void heap_sink(int i)
86
void heap_float(int i)
87
{
88
int p = i >> 1;
89
- while (i > 1 && V[H[i]].dis < V[H[p]].dis)
+ while (p > 1 && V[H[i]].dis < V[H[p]].dis)
90
91
pos[H[i]] = p;
92
pos[H[p]] = i;
93
int temp = H[i];
94
H[i] = H[p];
95
H[p] = temp;
96
+ i = p;
97
+ p = i >> 1;
98
}
99
100
101
int extract_min()
102
103
int res = H[1];
104
H[1] = H[heapsize--];
105
+ pos[H[1]] = 1;
106
heap_sink(1);
107
return res;
108
0 commit comments