-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
75 lines (65 loc) · 2.14 KB
/
test.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "utils.hpp"
#include "grahamScan.hpp"
#include "jarvisMarch.hpp"
#include "quickHull.hpp"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <chrono>
int main()
{
std::ofstream fout("out.txt");
int n;
std::cin >> n;
std::vector<Point> points;
for (int i = 0; i < n; i++)
{
long double x, y;
std::cin >> x >> y;
points.push_back(Point(x, y));
}
auto start = std::chrono::high_resolution_clock::now();
std::vector<Point> ch = grahamScan(points);
auto end = std::chrono::high_resolution_clock::now();
auto execution_time = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
fout << std::setprecision(18);
for (Point p : ch)
{
fout << p.x << " " << p.y << "\n";
}
long double ms = execution_time.count();
long double s = ms / 1000000;
std::cout << "Graham's Scan\nTime taken: \n"
<< "Microseconds: " << ms << "\n"
<< "Seconds: " << s << "\n==================\n";
start = std::chrono::high_resolution_clock::now();
ch = jarvisMarch(points);
end = std::chrono::high_resolution_clock::now();
execution_time = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
fout << std::setprecision(18);
for (Point p : ch)
{
fout << p.x << " " << p.y << "\n";
}
ms = execution_time.count();
s = ms / 1000000;
std::cout << "Jarvis March\nTime taken: \n"
<< "Microseconds: " << ms << "\n"
<< "Seconds: " << s << "\n==================\n";
start = std::chrono::high_resolution_clock::now();
ch = quickHull(points);
end = std::chrono::high_resolution_clock::now();
execution_time = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
fout << std::setprecision(18);
for (Point p : ch)
{
fout << p.x << " " << p.y << "\n";
}
ms = execution_time.count();
s = ms / 1000000;
std::cout << "QuickHull\nTime taken: \n"
<< "Microseconds: " << ms << "\n"
<< "Seconds: " << s << "\n";
std::cout << "\n ConvexHullSize: " << ch.size();
return 0;
}