/** * gen-array-with-opt -test-count <num> * -sum-n <num> * [-min-n <num>] * [-min-value <num>] [-max-value <num>] * [-value-bias <num>] * * Generate a test with `test-count` test cases, each test case is an * array. The sum of lengths of all arrays will equal `sum-n`. * * Arguments: * -test-count: specify the number of test cases. Required. * -sum-n: specify the sum of array lengths over all test cases. Required. * -min-n: specify the minimum array length for all test cases. Default: 1. * -min-value: specify the minimum value for the array element. Default: 1. * -max-value: specify the maximum value for the array element. Default: 10^9. * -value-bias: specify the bias for generating the value. The bigger the * _positive_ value-bias, the closer the element to max-value. The smaller the * _negative_ value-bias, the closer the element to min-value. See rnd.wnext() * function. Default: 0 (no bias). */ #include"testlib.h" #include<vector> usingnamespace std;
/* * It is another type of generators. It writes several files named * as test indices. * * For example, this generator writes 10 files (tests) from 1 to 10. * This type of generators is supported by Polygon too, but * stdout-generators are more preferred. * * The generator is for A+B problem, generates 10 tests where each * number is between 1 and 100, and tests grow with indices. */
#include"testlib.h"
usingnamespace std;
voidwriteTest(int test){ startTest(test); // 输出重定向到文件名为 test 对应值的文件中
int a = rnd.next(1, test * test); int b = rnd.next(1, test * test); println(a, b); }
vector<int> p(n); // p[i] is the parent of i-th vertex in 0-numeration without shuffling for (int i = 1; i < n; i++) p[i] = rnd.wnext(i, t);
vector<int> perm(n); for (int i = 0; i < n; i++) perm[i] = i; shuffle(perm.begin() + 1, perm.end());
vector<int> pp(n - 1); // pp[i] is the parent of (i+2)-nd vertex in 1-numeration after shuffling for (int i = 1; i < n; i++) pp[perm[i] - 1] = perm[p[i]] + 1;
vector<int> p(n); for (int i = 1; i < n; i++) p[i] = rnd.wnext(i, t); // t 越大越趋近于链,越小越趋近于菊花图
vector<int> perm = rnd.perm(n);
vector<pair<int, int>> edges; for (int i = 1; i < n; i++) if (rnd.next(2)) edges.push_back(make_pair(perm[i], perm[p[i]])); else edges.push_back(make_pair(perm[p[i]], perm[i]));
int n = opt<int>(1); int m = opt<int>(2); int t = opt<int>(3, 0);
vector<int> p(n); for (int i = 1; i < n; i++) p[i] = rnd.wnext(i, t); // t 越大越趋近于链,越小越趋近于菊花图
vector<int> perm = rnd.perm(n);
vector<pair<int, int>> edges; set<pair<int, int>> s; for (int i = 1; i < n; i++){ if (rnd.next(2)) { edges.push_back(make_pair(perm[i], perm[p[i]])); } else { edges.push_back(make_pair(perm[p[i]], perm[i])); } s.emplace(perm[i], perm[p[i]]); s.emplace(perm[p[i]], perm[i]); } for (int i = 0; i < m - n + 1; ++i) { while (true) { int x = rnd.next(n), y = rnd.next(n); if (x != y && s.find({x, y}) == s.end()) { s.emplace(x, y); s.emplace(y, x); edges.emplace_back(x, y); break; } } }