-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
56 lines (48 loc) · 1.25 KB
/
main.cpp
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <chrono>
#include <iostream>
#include "hex.hpp"
#include "puzzle.hpp"
#include "solver.hpp"
void print_answer(std::vector<Direction> &answer) {
for (int i = 0; i < answer.size(); i++) {
switch (answer[i]) {
case UP:
std::cout << "↑";
break;
case DOWN:
std::cout << "↓";
break;
case LEFT:
std::cout << "←";
break;
case RIGHT:
std::cout << "→";
break;
default:
break;
}
if ((i + 1) % 5 == 0) {
std::cout << " ";
}
}
std::cout << std::endl;
}
int main() {
std::string input;
while (std::cin >> input) {
Puzzle p(input);
Solver solver;
if (!p.solvable()) {
std::cout << "unsolvable" << std::endl;
continue;
}
auto start = std::chrono::high_resolution_clock::now();
auto ans = solver.solve(p);
auto end = std::chrono::high_resolution_clock::now();
auto duration =
std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
print_answer(ans);
std::cout << "time:" << duration.count() << "ms" << std::endl;
}
return 0;
}