6 struct pt { int x, y; char c; };
10 typedef long long int ll;
11 struct pt up[MAX], down[MAX];
14 int cmp(const void *X, const void *Y)
16 const struct pt *x = X, *y = Y;
24 ll sign(ll ax, ll ay, ll bx, ll by)
32 while (scanf("%d %d '%c'", &pt[N].x, &pt[N].y, &pt[N].c) == 3) {
33 //pt[N].y -= 4000000; pt[N].x -= 4000000;
36 qsort(pt, N, sizeof(pt[0]), cmp);
37 //for (int i=0; i<N; i++) printf("%d %d %c\n", pt[i].x, pt[i].y, pt[i].c);
38 //printf("%d\n", (int) sign(-2,1,2,0));
39 //printf("%d\n", (int) sign(-2,-1,2,0));
42 up[0] = down[0] = pt[0];
43 for (int i=1; i<N; i++) {
44 while (Nu > 1 && sign(up[Nu-2].x - up[Nu-1].x, up[Nu-2].y - up[Nu-1].y,
45 pt[i].x - up[Nu-1].x, pt[i].y - up[Nu-1].y) < 0)
48 while (Nd > 1 && sign(down[Nd-2].x - down[Nd-1].x, down[Nd-2].y - down[Nd-1].y,
49 pt[i].x - down[Nd-1].x, pt[i].y - down[Nd-1].y) > 0)
54 printf("### Upper hull:\n");
55 for (int i=0; i<Nu; i++)
56 printf("%7d %7d '%c'\n", up[i].x, up[i].y, up[i].c);
57 printf("### Lower hull:\n");
58 for (int i=0; i<Nd; i++)
59 printf("%7d %7d '%c'\n", down[i].x, down[i].y, down[i].c);