-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen.cpp
More file actions
39 lines (33 loc) · 1.03 KB
/
Copy pathgen.cpp
File metadata and controls
39 lines (33 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <vector>
#include <iostream>
#include <map>
using std::string;
using std::cout;
int rand_from_to(int lower, int upper) { // [ ]
int shift = rand() % (upper - lower + 1);
return lower + shift;
}
int main(int argc, char* argv[]) {
std::map<string, string> params;
for (int i = 1; i < argc; i++) {
string s = string(argv[i]);
if (s.find('=') != string::npos) {
auto pos = s.find('=');
params[s.substr(0, pos)] = s.substr(pos + 1);
}
}
std::srand(atoi(argv[1]));
int n = stoi(params["n"]);
int max_weight = stoi(params["max_weight"]);
long long cost = stoll(params["cost"]);
long double precision = 0.0;
if (params.count("precision"))
precision = std::stold(params["precision"]);
cout << n << " " << max_weight << "\n";
int approximate_weight = std::max(max_weight / n, 1);
for (int i = 0; i < n; i++) {
cout << rand() % (approximate_weight * 5) << " ";
cout << rand() % cost + 1 << "\n";
}
cout << precision;
}