Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Reverse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ std::string Reverse::reverse(std::string& toReverse)

for(std::string::reverse_iterator rit=toReverse.rbegin(); rit!=toReverse.rend(); ++rit)
{
ret.insert(ret.end(), *rit);
ret.push_back(*rit);
}
return ret;
}
}
20 changes: 9 additions & 11 deletions f1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,32 @@ using namespace std;

bool F1::run()
{

std::cout << "f1" << std::endl;

int N, K;

N = 10000;
K = 10000;
int N = 10000, K = 10000;

int total = ((N - 1) * (N - 2)) / 2;
if (K > total)
{
cout << -1 << endl;
return 0;
std::cout << -1 << std::endl;
return false;
}

vector<pair<int, int>> edges;
std::vector<std::pair<int, int>> edges;
edges.reserve(N - 1 + total - K); // Reserve memory 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;
}
}
42 changes: 24 additions & 18 deletions high_load.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <random>
#include "high_load.h"

#include <bits/stdc++.h>
Expand All @@ -10,22 +11,27 @@ typedef long long ll;
using namespace std;


bool BenchmarkRunner::benchmark(){
srand( (unsigned)time(NULL) );
for(int i=0;i<5000;i++) {
boost::container::flat_map<int, int> test_map;
boost::container::stable_vector<int> test_keys;
// 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);
}

for (int key : test_keys) {
test_map[key] += 1;
}
map<int, int> m;
bool BenchmarkRunner::benchmark() {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<int> dis(0, 99999);

for (int i = 0; i < 5000; i++) {
boost::container::flat_map<int, int> test_map;
std::vector<int> test_keys;
test_keys.reserve(1000);

// Insert random keys
for (int j = 0; j < 1000; j++) {
int random_key = dis(gen);
test_map.emplace(random_key, 0);
test_keys.emplace_back(random_key);
}

for (int key : test_keys) {
test_map[key] += 1;
}
return true;
}
std::map<int, int> m;
}
return true;
}
Empty file modified post_test.sh
100755 → 100644
Empty file.