@@ -37,8 +37,6 @@ void out(set<P> S, bool shuffle) {
3737 for (auto & [x, y]: V) { printf (" %d %d\n " , x, y); }
3838}
3939
40- const long double PI = acosl(-1 .0L );
41-
4240int main (int , char * argv[]) {
4341 long long seed = atoll (argv[1 ]);
4442 auto gen = Random (seed);
@@ -48,24 +46,38 @@ int main(int, char* argv[]) {
4846 int LIM = lims[seed % 2 ];
4947
5048 set<P> S;
51-
52- int n = gen.uniform <int >(100 , N_MAX );
53- int r = gen.uniform <int >(LIM /2 , LIM *3 /4 );
54- long double phi = gen.uniform <double >(0 , 2 * PI );
55- for (int i = 0 ; i < n; i++) {
56- long double theta = (long double )(i) * 2 * PI / (long double )(n) + phi;
57- long double ldx = r * cos (theta);
58- long double ldy = r * sin (theta);
59- int x = (int )(ldx);
60- int y = (int )(ldy);
61- while (y > 0 && x*x + (y+1 )*(y+1 ) <= r*r) y++;
62- while (y < 0 && x*x + (y-1 )*(y-1 ) <= r*r) y--;
63- y += gen.uniform <int >(-1 , 1 );
64- if (abs (x) > X_AND_Y_ABS_MAX ) x = (x < 0 ? -X_AND_Y_ABS_MAX : X_AND_Y_ABS_MAX );
65- if (abs (y) > X_AND_Y_ABS_MAX ) y = (y < 0 ? -X_AND_Y_ABS_MAX : X_AND_Y_ABS_MAX );
66- S.insert ({(int )x, (int )y});
49+
50+ int rx = gen.uniform <int >(LIM *5 /9 , LIM *2 /3 );
51+ int ry = gen.uniform <int >(LIM *5 /9 , LIM *2 /3 );
52+ int r_sq = rx*rx + ry*ry;
53+ int r = (int )sqrt (r_sq);
54+ int cx = gen.uniform <int >(-X_AND_Y_ABS_MAX + r*11 /10 , X_AND_Y_ABS_MAX - r*11 /10 );
55+ int cy = gen.uniform <int >(-X_AND_Y_ABS_MAX + r*11 /10 , X_AND_Y_ABS_MAX - r*11 /10 );
56+ int x = 0 , y = r;
57+ S.insert ({x + cx, y + cy});
58+ S.insert ({x + cx, -y + cy});
59+ const int dy[] = {-1 , 0 , 1 };
60+ while (x < r) {
61+ x++;
62+ while (y > 0 && x*x + y*y > r_sq) y--;
63+ int px = x;
64+ int py = y;
65+ for (int d = 0 ; d < 3 ; d++) {
66+ int nx = px;
67+ int ny = py + dy[d];
68+ if (abs (nx) > X_AND_Y_ABS_MAX ) nx = (nx < 0 ? -X_AND_Y_ABS_MAX : X_AND_Y_ABS_MAX );
69+ if (abs (ny) > X_AND_Y_ABS_MAX ) ny = (ny < 0 ? -X_AND_Y_ABS_MAX : X_AND_Y_ABS_MAX );
70+ int insert_flag = gen.uniform (0 , 15 );
71+ if (insert_flag & 1 ) S.insert ({nx + cx, ny + cy});
72+ if (insert_flag & 2 ) S.insert ({-nx + cx, ny + cy});
73+ if (insert_flag & 4 ) S.insert ({nx + cx, -ny + cy});
74+ if (insert_flag & 8 ) S.insert ({-nx + cx, -ny + cy});
75+ }
76+ }
77+ while (int (S.size ()) > N_MAX ) {
78+ auto it = S.begin ();
79+ S.erase (it);
6780 }
68-
6981 bool shuffle = gen.uniform_bool ();
7082 out (S, shuffle);
7183 return 0 ;
0 commit comments