Kulaga Grisha - #21
Conversation
| graph[tmp_from].push_back(tmp_to); | ||
| } | ||
|
|
||
| std::vector<int> vec = top_sort(graph); |
There was a problem hiding this comment.
warning: variable 'vec' of type 'std::vector' can be declared 'const' [misc-const-correctness]
| std::vector<int> vec = top_sort(graph); | |
| std::vector<int> const vec = top_sort(graph); |
| void dfs (int v, std::vector<bool> &used, std::vector<int> &result, std::vector< std::vector<int> > &graph) { | ||
| used[v] = true; | ||
| for (int i = 0; i < graph[v].size(); ++i) { | ||
| int to = graph[v][i]; |
There was a problem hiding this comment.
warning: variable 'to' of type 'int' can be declared 'const' [misc-const-correctness]
| int to = graph[v][i]; | |
| int const to = graph[v][i]; |
| int cost; | ||
| }; | ||
|
|
||
| int main () { |
There was a problem hiding this comment.
warning: an exception may be thrown in function 'main' which should not throw exceptions [bugprone-exception-escape]
int main () {
^| }; | ||
|
|
||
| int main () { | ||
| int n = 5, m = 8; |
There was a problem hiding this comment.
warning: variable 'n' of type 'int' can be declared 'const' [misc-const-correctness]
int n = 5, m = 8;
^| {1, 2, 3}, {1, 3, 2}, {1, 4, 2}, | ||
| {3, 2, 5}, {3, 1, 1}, | ||
| {4, 3, -3}}; | ||
| int v = 0; |
There was a problem hiding this comment.
warning: variable 'v' of type 'int' can be declared 'const' [misc-const-correctness]
| int v = 0; | |
| int const v = 0; |
| int dist = b - a + 1; | ||
| int log_dist = floor(log2(dist)); | ||
|
|
||
| int k = std::min (vec2D[log_dist][a], vec2D[log_dist][dist - pow(2, log_dist)]); |
There was a problem hiding this comment.
warning: narrowing conversion from 'double' to 'size_type' (aka 'unsigned long') [cppcoreguidelines-narrowing-conversions]
int k = std::min (vec2D[log_dist][a], vec2D[log_dist][dist - pow(2, log_dist)]);
^| vec.push_back(tmp); | ||
| } | ||
|
|
||
| std::vector< std::vector<int> > vec2D = table_construct(n, vec); |
There was a problem hiding this comment.
warning: variable 'vec2D' of type 'std::vector<std::vector>' can be declared 'const' [misc-const-correctness]
| std::vector< std::vector<int> > vec2D = table_construct(n, vec); | |
| std::vector< std::vector<int> > const vec2D = table_construct(n, vec); |
| int a, b; | ||
| std::cin >> a >> b; | ||
|
|
||
| int k = RMQ(a, b, vec2D); |
There was a problem hiding this comment.
warning: variable 'k' of type 'int' can be declared 'const' [misc-const-correctness]
| int k = RMQ(a, b, vec2D); | |
| int const k = RMQ(a, b, vec2D); |
| int a, b; | ||
| std::cin >> a >> b; | ||
|
|
||
| int k = RMQ(a, b, vec2D); |
There was a problem hiding this comment.
warning: Value stored to 'k' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
int k = RMQ(a, b, vec2D);
^Additional context
task_05/src/main.cpp:25: Value stored to 'k' during its initialization is never read
int k = RMQ(a, b, vec2D);
^| @@ -1,6 +1,35 @@ | |||
|
|
|||
| #include <gtest/gtest.h> | |||
There was a problem hiding this comment.
warning: 'gtest/gtest.h' file not found [clang-diagnostic-error]
#include <gtest/gtest.h>
^| graph[tmp_from].push_back(tmp_to); | ||
| } | ||
|
|
||
| std::vector<int> vec = top_sort(graph); |
There was a problem hiding this comment.
warning: variable 'vec' of type 'std::vector' can be declared 'const' [misc-const-correctness]
| std::vector<int> vec = top_sort(graph); | |
| std::vector<int> const vec = top_sort(graph); |
| std::vector<std::vector<int> > &graph) { | ||
| used[v] = true; | ||
| for (int i = 0; i < graph[v].size(); ++i) { | ||
| int to = graph[v][i]; |
There was a problem hiding this comment.
warning: variable 'to' of type 'int' can be declared 'const' [misc-const-correctness]
| int to = graph[v][i]; | |
| int const to = graph[v][i]; |
|
|
||
| int start, end; | ||
| cin >> start >> end; | ||
| int k = Deijkstra(start, end, graph); |
There was a problem hiding this comment.
warning: variable 'k' of type 'int' can be declared 'const' [misc-const-correctness]
| int k = Deijkstra(start, end, graph); | |
| int const k = Deijkstra(start, end, graph); |
| const int INF = 1e9; | ||
|
|
||
| std::vector<std::vector<int> > table_construct(int n, std::vector<int> &vec) { | ||
| int new_size = ceil(log2(n)); |
There was a problem hiding this comment.
warning: variable 'new_size' of type 'int' can be declared 'const' [misc-const-correctness]
| int new_size = ceil(log2(n)); | |
| int const new_size = ceil(log2(n)); |
| int tmp = 1; | ||
| int count = 1; | ||
| std::vector<std::vector<int> > vec2D; | ||
| vec2D.resize(pow(2, new_size)); |
There was a problem hiding this comment.
warning: narrowing conversion from 'double' to 'size_type' (aka 'unsigned long') [cppcoreguidelines-narrowing-conversions]
vec2D.resize(pow(2, new_size));
^| int dist = b - a + 1; | ||
| int log_dist = floor(log2(dist)); | ||
|
|
||
| int k = |
There was a problem hiding this comment.
warning: variable 'k' of type 'int' can be declared 'const' [misc-const-correctness]
| int k = | |
| int const k = |
| int log_dist = floor(log2(dist)); | ||
|
|
||
| int k = | ||
| std::min(vec2D[log_dist][a], vec2D[log_dist][dist - pow(2, log_dist)]); |
There was a problem hiding this comment.
warning: narrowing conversion from 'double' to 'size_type' (aka 'unsigned long') [cppcoreguidelines-narrowing-conversions]
std::min(vec2D[log_dist][a], vec2D[log_dist][dist - pow(2, log_dist)]);
^| vec.push_back(tmp); | ||
| } | ||
|
|
||
| std::vector<std::vector<int> > vec2D = table_construct(n, vec); |
There was a problem hiding this comment.
warning: variable 'vec2D' of type 'std::vector<std::vector>' can be declared 'const' [misc-const-correctness]
| std::vector<std::vector<int> > vec2D = table_construct(n, vec); | |
| std::vector<std::vector<int> > const vec2D = table_construct(n, vec); |
| int a, b; | ||
| std::cin >> a >> b; | ||
|
|
||
| int k = RMQ(a, b, vec2D); |
There was a problem hiding this comment.
warning: variable 'k' of type 'int' can be declared 'const' [misc-const-correctness]
| int k = RMQ(a, b, vec2D); | |
| int const k = RMQ(a, b, vec2D); |
| int a, b; | ||
| std::cin >> a >> b; | ||
|
|
||
| int k = RMQ(a, b, vec2D); |
There was a problem hiding this comment.
warning: Value stored to 'k' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
int k = RMQ(a, b, vec2D);
^Additional context
task_05/src/main.cpp:24: Value stored to 'k' during its initialization is never read
int k = RMQ(a, b, vec2D);
^| int cost; | ||
| }; | ||
|
|
||
| int main() { |
There was a problem hiding this comment.
warning: an exception may be thrown in function 'main' which should not throw exceptions [bugprone-exception-escape]
int main() {
^| }; | ||
|
|
||
| int main() { | ||
| int n = 5, m = 8; |
There was a problem hiding this comment.
warning: variable 'n' of type 'int' can be declared 'const' [misc-const-correctness]
int n = 5, m = 8;
^| std::vector<int> vec(n, INF); | ||
| std::vector<edge> edges = {{0, 1, -1}, {0, 2, 4}, {1, 2, 3}, {1, 3, 2}, | ||
| {1, 4, 2}, {3, 2, 5}, {3, 1, 1}, {4, 3, -3}}; | ||
| int v = 0; |
There was a problem hiding this comment.
warning: variable 'v' of type 'int' can be declared 'const' [misc-const-correctness]
| int v = 0; | |
| int const v = 0; |
| #include "AllFunc.hpp" | ||
|
|
||
| void AllFunc(std::vector<std::vector<int> > &graph, | ||
| std::set<std::pair<int, int> > &result, std::set<int> &cpvector) { |
There was a problem hiding this comment.
warning: parameter 'cpvector' is unused [misc-unused-parameters]
| std::set<std::pair<int, int> > &result, std::set<int> &cpvector) { | |
| std::set<std::pair<int, int> > &result, std::set<int> & /*cpvector*/) { |
| @@ -1,6 +1,72 @@ | |||
|
|
|||
| #include <gtest/gtest.h> | |||
There was a problem hiding this comment.
warning: 'gtest/gtest.h' file not found [clang-diagnostic-error]
#include <gtest/gtest.h>
^| if (l == r) | ||
| lca_tree[i] = lca_dfs_list[l]; | ||
| else { | ||
| int m = (l + r) >> 1; |
There was a problem hiding this comment.
warning: variable 'm' of type 'int' can be declared 'const' [misc-const-correctness]
| int m = (l + r) >> 1; | |
| int const m = (l + r) >> 1; |
| if (graph.size() == 1) { | ||
| OnlyRoot = true; | ||
| } else { | ||
| int n = (int)graph.size(); |
There was a problem hiding this comment.
warning: variable 'n' of type 'int' can be declared 'const' [misc-const-correctness]
| int n = (int)graph.size(); | |
| int const n = (int)graph.size(); |
| } else { | ||
| int n = (int)graph.size(); | ||
| lca_h.resize(n); | ||
| lca_dfs_list.reserve(n * 2); |
There was a problem hiding this comment.
warning: performing an implicit widening conversion to type 'size_type' (aka 'unsigned long') of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]
lca_dfs_list.reserve(n * 2);
^Additional context
task_06/src/LCA.cpp:43: make conversion explicit to silence this warning
lca_dfs_list.reserve(n * 2);
^task_06/src/LCA.cpp:43: perform multiplication in a wider type
lca_dfs_list.reserve(n * 2);
^| int sm = (sl + sr) >> 1; | ||
| if (r <= sm) return lca_tree_min(i + i, sl, sm, l, r); | ||
| if (l > sm) return lca_tree_min(i + i + 1, sm + 1, sr, l, r); | ||
| int ans1 = lca_tree_min(i + i, sl, sm, l, sm); |
There was a problem hiding this comment.
warning: variable 'ans1' of type 'int' can be declared 'const' [misc-const-correctness]
| int ans1 = lca_tree_min(i + i, sl, sm, l, sm); | |
| int const ans1 = lca_tree_min(i + i, sl, sm, l, sm); |
| if (r <= sm) return lca_tree_min(i + i, sl, sm, l, r); | ||
| if (l > sm) return lca_tree_min(i + i + 1, sm + 1, sr, l, r); | ||
| int ans1 = lca_tree_min(i + i, sl, sm, l, sm); | ||
| int ans2 = lca_tree_min(i + i + 1, sm + 1, sr, sm + 1, r); |
There was a problem hiding this comment.
warning: variable 'ans2' of type 'int' can be declared 'const' [misc-const-correctness]
| int ans2 = lca_tree_min(i + i + 1, sm + 1, sr, sm + 1, r); | |
| int const ans2 = lca_tree_min(i + i + 1, sm + 1, sr, sm + 1, r); |
| @@ -1,6 +1,42 @@ | |||
|
|
|||
| #include <gtest/gtest.h> | |||
There was a problem hiding this comment.
warning: 'gtest/gtest.h' file not found [clang-diagnostic-error]
#include <gtest/gtest.h>
^| } | ||
|
|
||
| TEST(LCA, Empty) { | ||
| graph g = {}; |
There was a problem hiding this comment.
warning: variable 'g' of type 'graph' (aka 'int') can be declared 'const' [misc-const-correctness]
| graph g = {}; | |
| graph const g = {}; |
| } | ||
|
|
||
| TEST(LCA, Only_Root) { | ||
| graph g = {{}}; |
There was a problem hiding this comment.
warning: variable 'g' of type 'graph' (aka 'int') can be declared 'const' [misc-const-correctness]
| graph g = {{}}; | |
| graph const g = {{}}; |
| std::vector<std::vector<int>> Johnson(std::vector<edge> &edges, int m, int n) { | ||
| std::vector<int> vec(n, INF); | ||
| std::vector<edge> tmp_edges = edges; | ||
| int v = 0; |
There was a problem hiding this comment.
warning: variable 'v' of type 'int' can be declared 'const' [misc-const-correctness]
| int v = 0; | |
| int const v = 0; |
| } | ||
| } | ||
| } | ||
| if (x != -1) { |
There was a problem hiding this comment.
warning: The left operand of '!=' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
if (x != -1) {
^Additional context
task_03/src/Johnson.cpp:9: Assuming 'i' is >= 'n'
for (int i = 0; i < n; ++i) {
^task_03/src/Johnson.cpp:9: Loop condition is false. Execution continues on line 14
for (int i = 0; i < n; ++i) {
^task_03/src/Johnson.cpp:16: 'x' declared without an initial value
int x;
^task_03/src/Johnson.cpp:17: 'i' is >= 'n'
for (int i = 0; i < n; ++i) {
^task_03/src/Johnson.cpp:17: Loop condition is false. Execution continues on line 31
for (int i = 0; i < n; ++i) {
^task_03/src/Johnson.cpp:30: The left operand of '!=' is a garbage value
if (x != -1) {
^| } | ||
|
|
||
| for (int i = 0; i < n; ++i) { | ||
| res.push_back(Deijkstra(i, graph)); |
There was a problem hiding this comment.
warning: 'push_back' is called inside a loop; consider pre-allocating the container capacity before the loop [performance-inefficient-vector-operation]
task_03/src/Johnson.cpp:46:
- for (int i = 0; i < n; ++i) {
+ res.reserve(n);
+ for (int i = 0; i < n; ++i) {| @@ -1,6 +1,42 @@ | |||
|
|
|||
| #include <gtest/gtest.h> | |||
There was a problem hiding this comment.
warning: 'gtest/gtest.h' file not found [clang-diagnostic-error]
#include <gtest/gtest.h>
^
No description provided.