| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "krasavin_a_max_neighbor_diff/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cmath> | ||
| 5 | #include <cstdlib> | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | #include "krasavin_a_max_neighbor_diff/common/include/common.hpp" | ||
| 9 | |||
| 10 | namespace krasavin_a_max_neighbor_diff { | ||
| 11 | |||
| 12 |
1/2✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
|
80 | KrasavinAMaxNeighborDiffSEQ::KrasavinAMaxNeighborDiffSEQ(const InType &in) { |
| 13 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 14 |
1/2✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
|
80 | GetInput() = in; |
| 15 | 80 | GetOutput() = 0; | |
| 16 | 80 | } | |
| 17 | |||
| 18 | 80 | bool KrasavinAMaxNeighborDiffSEQ::ValidationImpl() { | |
| 19 | 80 | return true; | |
| 20 | } | ||
| 21 | |||
| 22 | 80 | bool KrasavinAMaxNeighborDiffSEQ::PreProcessingImpl() { | |
| 23 | 80 | return true; | |
| 24 | } | ||
| 25 | |||
| 26 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 64 times.
|
80 | bool KrasavinAMaxNeighborDiffSEQ::RunImpl() { |
| 27 | const std::vector<int> &vec = GetInput(); | ||
| 28 | std::size_t n = vec.size(); | ||
| 29 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 64 times.
|
80 | if (n < 2) { |
| 30 | 16 | GetOutput() = 0; | |
| 31 | 16 | return true; | |
| 32 | } | ||
| 33 | |||
| 34 | 64 | int max_diff = 0; | |
| 35 |
2/2✓ Branch 0 taken 224 times.
✓ Branch 1 taken 64 times.
|
288 | for (std::size_t i = 0; i < n - 1; i++) { |
| 36 | 224 | int diff = std::abs(vec[i + 1] - vec[i]); | |
| 37 | 224 | max_diff = std::max(diff, max_diff); | |
| 38 | } | ||
| 39 | |||
| 40 | 64 | GetOutput() = max_diff; | |
| 41 | 64 | return true; | |
| 42 | } | ||
| 43 | |||
| 44 | 80 | bool KrasavinAMaxNeighborDiffSEQ::PostProcessingImpl() { | |
| 45 | 80 | return true; | |
| 46 | } | ||
| 47 | |||
| 48 | } // namespace krasavin_a_max_neighbor_diff | ||
| 49 |