#include #include #include #include using namespace std; typedef vector VS; const int CASES = 50; const int MAXN = 100; const int MAXL = 20; int num_cases = CASES; void dump(const VS& v) { cout << v.size() << endl; for (auto &s : v) cout << s << endl; --num_cases; } void genSample() { VS v1 = {"saskatoon", "toronto", "winnipeg", "toronto", "vancouver", "saskatoon", "toronto"}; dump(v1); VS v2 = {"edmonton", "edmonton", "edmonton"}; dump(v2); } string randStr(int l) { string s; for (int i = 0; i < l; ++i) s.push_back('a' + rand()%26); return s; } //generate n random trips that visit m distinct cities //*very* tiny probability that the number of distinct cities is < m void genRand(int n, int m) { VS trips; for (int i = 0; i < m; ++i) trips.push_back(randStr(MAXL)); for (int i = m; i < n; ++i) trips.push_back(trips[rand()%m]); for (int i = n-1; i > 0; --i) swap(trips[i], trips[rand()%(i+1)]); dump(trips); } int main() { cout << num_cases << endl; genSample(); genRand(1, 1); genRand(2, 1); genRand(2, 2); genRand(3, 1); genRand(3, 2); genRand(3, 3); genRand(MAXN, 1); genRand(MAXN, 2); genRand(MAXN, MAXN-1); genRand(MAXN, MAXN); while (num_cases) { int n = 1+rand()%MAXN; int m = 1+rand()%n; genRand(n, m); } return 0; }