diff --git a/f1.cpp b/f1.cpp index 97ea106..23b7a71 100644 --- a/f1.cpp +++ b/f1.cpp @@ -29,18 +29,19 @@ bool F1::run() } vector> edges; + edges.reserve(N - 1 + (total - K)); // Reserve space to avoid reallocations for (int i = 2; i <= N; ++i) { - edges.push_back({1, i}); + edges.emplace_back(1, i); } for (int i = 2; i < N && total > K; ++i) { for (int j = i + 1; j <= N && total > K; ++j, --total) { - edges.push_back({i, j}); + edges.emplace_back(i, j); } } return true; -} +} \ No newline at end of file diff --git a/high_load.cpp b/high_load.cpp index 836fe26..d778aca 100644 --- a/high_load.cpp +++ b/high_load.cpp @@ -1,3 +1,8 @@ +#include +#include +#include +#include +#include #include "high_load.h" #include @@ -18,8 +23,10 @@ bool BenchmarkRunner::benchmark(){ // Insert random keys for (int i = 0; i < 1000; i++) { int random_key = rand() % 100000; - test_map[random_key] = 0; - test_keys.push_back(random_key); + auto result = test_map.insert(std::make_pair(random_key, 0)); + if (result.second) { + test_keys.push_back(random_key); + } } for (int key : test_keys) { @@ -28,4 +35,4 @@ bool BenchmarkRunner::benchmark(){ map m; } return true; -} +} \ No newline at end of file diff --git a/post_test.sh b/post_test.sh old mode 100755 new mode 100644