feat: partially formatted new problem
This commit is contained in:
99
min-sum-path-2d/src/generator.cpp
Normal file
99
min-sum-path-2d/src/generator.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
#include "testlib.h"
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int MIN_N = 1;
|
||||
const int MAX_N = 1000;
|
||||
|
||||
const int MIN_A = 1;
|
||||
const int MAX_A = 100;
|
||||
|
||||
const int rnd_test_n = 100;
|
||||
|
||||
template <typename T>
|
||||
void append(vector<T> &dest, const vector<T> &orig) {
|
||||
dest.insert(dest.end(), orig.begin(), orig.end());
|
||||
}
|
||||
|
||||
string output_tc(int n, int m, vector<vector<int>> grid) {
|
||||
ostringstream oss;
|
||||
oss << n << " " << m << "\n";
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
if (j) oss << " ";
|
||||
oss << grid[i][j];
|
||||
}
|
||||
oss << "\n";
|
||||
}
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
vector<vector<int>> random_grid(int n, int m) {
|
||||
vector<vector<int>> g(n, vector<int>(m));
|
||||
for (int i = 0; i < n; i++)
|
||||
for (int j = 0; j < m; j++)
|
||||
g[i][j] = rnd.next(MIN_A, MAX_A);
|
||||
return g;
|
||||
}
|
||||
|
||||
vector<string> generate_sample_tests() {
|
||||
vector<string> tests;
|
||||
tests.push_back(output_tc(1, 1, {{5}}));
|
||||
tests.push_back(output_tc(2, 2, {{1, 3}, {2, 4}}));
|
||||
tests.push_back(output_tc(3, 3, {{1,2,3},{4,5,6},{7,8,9}}));
|
||||
return tests;
|
||||
}
|
||||
|
||||
vector<string> generate_manual_tests() {
|
||||
vector<string> tests;
|
||||
tests.push_back(output_tc(5, 5, vector<vector<int>>(5, vector<int>(5, 1))));
|
||||
tests.push_back(output_tc(5, 5, vector<vector<int>>(5, vector<int>(5, 100))));
|
||||
return tests;
|
||||
}
|
||||
|
||||
string rnd_test(int i){
|
||||
int max_lim = MAX_N;
|
||||
|
||||
if (i < rnd_test_n / 3)
|
||||
max_lim = 10;
|
||||
else if (i < rnd_test_n / 2)
|
||||
max_lim = 50;
|
||||
|
||||
int n = rnd.next(MIN_N, max_lim);
|
||||
int m = rnd.next(MIN_N, max_lim);
|
||||
|
||||
return output_tc(n, m, random_grid(n, m));
|
||||
}
|
||||
|
||||
vector<string> generate_random_tests() {
|
||||
vector<string> tests;
|
||||
for (int i = 0; i < rnd_test_n; i++)
|
||||
tests.push_back(rnd_test(i));
|
||||
return tests;
|
||||
}
|
||||
|
||||
string extreme_test_1(){
|
||||
return output_tc(MAX_N, MAX_N, random_grid(MAX_N, MAX_N));
|
||||
}
|
||||
|
||||
vector<string> generate_extreme_tests(){
|
||||
vector<string> tests;
|
||||
tests.push_back(extreme_test_1());
|
||||
return tests;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
registerGen(argc, argv, 1);
|
||||
vector<string> tests;
|
||||
append(tests, generate_sample_tests());
|
||||
append(tests, generate_manual_tests());
|
||||
append(tests, generate_random_tests());
|
||||
append(tests, generate_extreme_tests());
|
||||
size_t test = 0;
|
||||
for (const auto &t : tests) {
|
||||
startTest(++test);
|
||||
cout << t;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user