#include #include #include #include #include #include #include #include #include #include #include using namespace std; int N, M, F; void print_airplanes() { for (int i = 0; i < M; i++) { int base = 1 + rand()%N; int speed = rand()%(512 - 16) + 16; int cost = rand()%(256 - 16) + 16; int cap = rand()%(512 - 16) + 16; printf ("%d %d %d %d\n", base, speed, cost, cap); } } vector l, r; bool a[64][64]; void build_connected_graph() { l.push_back (0); for (int i = 1; i < N; i++) { r.push_back (i); } while (!r.empty()) { int x = rand()%l.size(); int y = rand()%r.size(); a[r[y]][l[x]] = a[l[x]][r[y]] = 1; l.push_back (r[y]); r.erase (r.begin() + y); } int f = F - (N - 1)*2; while (f > 0) { int x = rand()%N; int y = rand()%N; if (x == y or a[x][y]) continue; f -= 2; a[x][y] = a[y][x] = 1; } } void build_random_graph() { int f = F; while (f > 0) { int x = rand()%N; int y = rand()%N; if (x == y or a[x][y]) continue; f -= 2; a[x][y] = a[y][x] = 1; } } bool used[64][64][4][17]; void print_flights() { for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) if (a[i][j]) { int dist = 64 + rand()%(512 - 64); int K = rand()%16; printf ("%d %d %d %d\n", i + 1, j + 1, dist, K); for (int k = 0; k < K; k++) { int month = rand()%4; int starth = rand()%12; int endh = starth + rand()%(12 - starth) + 1; if (starth >= endh) {k--; continue;} starth += 4; endh += 4; if (endh > 16) {k--; continue;} if (used[i][j][month][starth]) {k--; continue;} used[i][j][month][starth] = 1; printf ("%d %d %d %d %d\n", starth, endh, month + 1, 1 + rand()%512, 16 + rand()%(512 - 16)); } } } int main(int argc, char *argv[]) { if (argc != 3) { printf ("You should provide exactly two arguments - the group number and the seed for the test."); return 0; } int group, seed; sscanf (argv[1], "%d", &group); sscanf (argv[2], "%d", &seed); srand (seed); if (0 < group and group < 3) N = 25, M = 25, F = 500; else if (2 < group and group < 5) N = 50, M = 50, F = 1000; else { printf ("There are exactly four groups allowed - 1, 2, 3 and 4."); return 0; } freopen ("flights.in", "w", stdout); printf ("%d %d %d\n", N, M, F); print_airplanes(); if (group == 1 or group == 4) build_connected_graph(); else build_random_graph(); print_flights(); return 0; }