#include "testlib.h" #include 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 void append(vector &dest, const vector &orig) { dest.insert(dest.end(), orig.begin(), orig.end()); } string output_tc(int n, int m, vector> 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> random_grid(int n, int m) { vector> g(n, vector(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 generate_sample_tests() { vector 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 generate_manual_tests() { vector tests; tests.push_back(output_tc(5, 5, vector>(5, vector(5, 1)))); tests.push_back(output_tc(5, 5, vector>(5, vector(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 generate_random_tests() { vector 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 generate_extreme_tests(){ vector tests; tests.push_back(extreme_test_1()); return tests; } int main(int argc, char *argv[]) { registerGen(argc, argv, 1); vector 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; }