// 02: a bunch of random cases // 03: some require tie-breaking // 04: shorter class names so there is more need to deal with the // "default middle class" rule // 05: a few very small cases // 06: max case #include #include #include #include using namespace std; random_device rd; default_random_engine e1(rd()); int rand_int(int low, int high) { uniform_int_distribution uniform_dist(low, high); return uniform_dist(e1); } string rand_str(int len) { string s; for (int i = 0; i < len; i++) { int x = rand_int(0, 25); s += (char)('a' + x); } return s; } string rand_class() { const string names[] = { "upper", "middle", "lower" }; int len = rand_int(10, 10); string s; for (int i = 0; i < len; i++) { if (i) s += '-'; s += names[rand_int(0,2)]; } return s; } int main() { // just generate a bunch of random instances int T = 500; cout << T << endl; for (int i = 0; i < T; i++) { string names[100]; int n = rand_int(100,100); cout << n << endl; string last_class; for (int j = 0; j < n; j++) { do { names[j] = rand_str(rand_int(30,30)); } while (find(names, names+j, names[j]) != names+j); if (j % 2 == 0 || true) { cout << names[j] << ": " << (last_class = rand_class()) << " class" << endl; } else { cout << names[j] << ": " << (last_class) << " class" << endl; } } } return 0; }