-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathid0083.c
More file actions
26 lines (19 loc) · 724 Bytes
/
id0083.c
File metadata and controls
26 lines (19 loc) · 724 Bytes
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
// Licensed under the MIT License.
// Path Sum: Four Ways
#include "../lib/grid_neighbor_iterator.h"
#include "../lib/euler.h"
#include "../lib/priority_queue.h"
int main(void)
{
char lineBuffer[512];
struct GridGraph grid;
struct Coordinate source = { 0 };
clock_t start = clock();
euler_ok(grid_graph(&grid, 80, 80));
grid_graph_deserialize(&grid, stdin, lineBuffer, sizeof lineBuffer);
euler_ok(grid_min_path(&grid, &source, DIRECTIONS_ALL));
int sourceWeight = grid.edges[source.i * grid.m + source.j].weight;
int distance = grid.edges[(grid.m - 1) * grid.m + grid.n - 1].distance;
finalize_grid_graph(&grid);
return euler_submit(83, sourceWeight + distance, start);
}