| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cstdint> | ||
| 5 | #include <tuple> | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | #include "task/include/task.hpp" | ||
| 9 | |||
| 10 | namespace romanov_m_jarvis_prohod { | ||
| 11 | |||
| 12 | struct Point { | ||
| 13 | int x{}; | ||
| 14 | int y{}; | ||
| 15 | |||
| 16 | constexpr bool operator==(const Point &other) const noexcept { | ||
| 17 | ✗ | return x == other.x && y == other.y; | |
| 18 | } | ||
| 19 | |||
| 20 | constexpr bool operator!=(const Point &other) const noexcept { | ||
| 21 | return !(*this == other); | ||
| 22 | } | ||
| 23 | }; | ||
| 24 | |||
| 25 | constexpr bool IsEqual(const Point &p1, const Point &p2) noexcept { | ||
| 26 | return p1.x == p2.x && p1.y == p2.y; | ||
| 27 | } | ||
| 28 | |||
| 29 | constexpr int64_t CrossCalculate(const Point &p1, const Point &p2, const Point &p3) noexcept { | ||
| 30 | 661 | return (static_cast<int64_t>(p2.x - p1.x) * static_cast<int64_t>(p3.y - p1.y)) - | |
| 31 |
2/2✓ Branch 0 taken 71 times.
✓ Branch 1 taken 590 times.
|
661 | (static_cast<int64_t>(p2.y - p1.y) * static_cast<int64_t>(p3.x - p1.x)); |
| 32 | } | ||
| 33 | |||
| 34 | constexpr int SqDistance(const Point &p1, const Point &p2) noexcept { | ||
| 35 | const int dx = p2.x - p1.x; | ||
| 36 | const int dy = p2.y - p1.y; | ||
| 37 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 228 times.
|
246 | return (dx * dx) + (dy * dy); |
| 38 | } | ||
| 39 | |||
| 40 | inline Point FindStartPoint(const std::vector<Point> &points) { | ||
| 41 | return *std::ranges::min_element( | ||
| 42 | points, [](const Point &a, const Point &b) { return a.x < b.x || (a.x == b.x && a.y < b.y); }); | ||
| 43 | } | ||
| 44 | |||
| 45 | using InType = std::vector<Point>; | ||
| 46 | using OutType = std::vector<Point>; | ||
| 47 | using TestType = std::tuple<int, std::vector<Point>, std::vector<Point>>; | ||
| 48 | using BaseTask = ppc::task::Task<InType, OutType>; | ||
| 49 | |||
| 50 | } // namespace romanov_m_jarvis_prohod | ||
| 51 |