-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathg04.c
169 lines (157 loc) · 3.15 KB
/
g04.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXN 10000 /* intersections */
#define MAXN0 1000
#define MAXM 200000 /* streets */
#define MAXK 10000 /* machines */
static void test00(void)
{
printf("5 5 2\n");
printf("0 1\n");
printf("1 2\n");
printf("2 3\n");
printf("3 4\n");
printf("4 0\n");
}
static void test01(void)
{
printf("5 10 5\n");
printf("0 1\n");
printf("0 2\n");
printf("0 3\n");
printf("0 4\n");
printf("1 2\n");
printf("1 3\n");
printf("1 4\n");
printf("2 3\n");
printf("2 4\n");
printf("3 4\n");
}
static void test02(void)
{
printf("5 10 3\n");
printf("0 1\n");
printf("0 2\n");
printf("0 3\n");
printf("0 4\n");
printf("1 2\n");
printf("1 3\n");
printf("1 4\n");
printf("2 3\n");
printf("2 4\n");
printf("3 4\n");
}
static void test03(void)
{
int n = (MAXN0 & 1) ? MAXN0 : MAXN0 - 1;
int m = n * (n - 1) / 2;
int i, j;
printf("%d %d %d\n", n, m, 2);
for (i = 0; i < n; i++)
for (j = i + 1; j < n; j++)
printf("%d %d\n", i, j);
}
static void test04(void)
{
int n = (MAXN0 & 1) ? MAXN0 : MAXN0 - 1;
int m = n * (n - 1) / 2;
int i, j;
printf("%d %d %d\n", n, m, 7);
for (i = 0; i < n; i++)
for (j = i + 1; j < n; j++)
printf("%d %d\n", i, j);
}
static void test05(void)
{
int n = (MAXN0 & 1) ? MAXN0 : MAXN0 - 1;
int m = n * (n - 1) / 2;
int i, j;
printf("%d %d %d\n", n, m, MAXK);
for (i = 0; i < n; i++)
for (j = i + 1; j < n; j++)
printf("%d %d\n", i, j);
}
static void test06(void)
{
int n0 = MAXN0 | 1;
int m0 = n0 * (n0 - 1) / 2;
int n = n0 * 2;
int m = m0 * 2 + n0;
int i, j;
printf("%d %d %d\n", n, m, 17);
for (i = 0; i < n0; i++)
for (j = i + 1; j < n0; j++)
printf("%d %d\n", i, j);
for (i = 0; i < n0; i++)
printf("%d %d\n", i, n0 + i);
for (i = 0; i < n0; i++)
for (j = i + 1; j < n0; j++)
printf("%d %d\n", n0 + i, n0 + j);
}
static void test07(void)
{
int n = MAXN;
int m = n;
int i;
printf("%d %d %d\n", n, m, MAXK / 10);
for (i = 0; i < n; i++)
printf("%d %d\n", i, i + 1 < n ? i + 1 : 0);
}
static void test08(void)
{
int n = MAXN;
int m = n * 4;
int i;
printf("%d %d %d\n", n, m, 20);
for (i = 0; i < n; i++)
printf("%d %d\n", i, (i + 1) % n);
for (i = 0; i < n; i++)
printf("%d %d\n", i, (i + 3) % n);
for (i = 0; i < n; i++)
printf("%d %d\n", i, (i + 5) % n);
for (i = 0; i < n; i++)
printf("%d %d\n", i, (i + 7) % n);
}
static void test09(void)
{
int n = MAXN;
int m = n * 3;
int i;
printf("%d %d %d\n", n, m, 93);
for (i = 0; i < n; i++)
printf("%d %d\n", i, (i + 20) % n);
for (i = 0; i < n; i++)
printf("%d %d\n", i, (i + 47) % n);
for (i = 0; i < n; i++)
printf("%d %d\n", i, (i + 50) % n);
}
int main(int argc, char *argv[])
{
if (argc != 2)
return 1;
else if (atoi(argv[1]) == 0)
test00();
else if (atoi(argv[1]) == 1)
test01();
else if (atoi(argv[1]) == 2)
test02();
else if (atoi(argv[1]) == 3)
test03();
else if (atoi(argv[1]) == 4)
test04();
else if (atoi(argv[1]) == 5)
test05();
else if (atoi(argv[1]) == 6)
test06();
else if (atoi(argv[1]) == 7)
test07();
else if (atoi(argv[1]) == 8)
test08();
else if (atoi(argv[1]) == 9)
test09();
else
return 1;
return 0;
}