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
| #include <bits/stdc++.h> #define fi first #define se second #define pb(x) emplace_back(x) using PLL = std::pair<long long, long long>; using LL = long long; const int N = 1e5 + 100; int n, stk[N], top; PLL a[N]; bool vis[N]; std::pair<int, PLL> ans; std::vector<int> b; std::map<PLL, int> ha; int ne(int x){ return x + 1 - top + ((x + 1 - top) >> 31 & top); } PLL operator - (PLL x, PLL y){ return {x.fi - y.fi, x.se - y.se}; } PLL operator + (PLL x, PLL y){ return {x.fi + y.fi, x.se + y.se}; } PLL operator * (PLL x, LL y){ return {x.fi * y, x.se * y}; } LL operator * (PLL x, PLL y){ return x.fi * y.se - x.se * y.fi; } LL area(PLL x, PLL y, PLL z){ return (y - x) * (z - x); } void convex(PLL *x, int n) { std::sort(x, x + n); top = 0; for (int i = 0; i < n; ++i) { while (top >= 2 && area(x[stk[top - 2]], x[stk[top - 1]], x[i]) < 0) vis[stk[--top]] = false; vis[stk[top++] = i] = true; } vis[0] = false; for (int i = n - 1; ~i; --i) if (!vis[i]) { while (top >= 2 && area(x[stk[top - 2]], x[stk[top - 1]], x[i]) < 0) --top; stk[top++] = i; } --top; } void upd(int l, int r) { if (l == r) return ; if (r == ne(l)) { if (ans.fi < 1) ans = {1, a[stk[r]] - a[stk[l]]}; return ; } r = ne(r); PLL x = a[stk[l + 1]] - a[stk[l]]; int st2 = -1, z1 = 0, z2 = 0; for (int i = ne(l); i != r; i = ne(i)) if (a[stk[i]] != a[stk[l]] + x * (z1 + 1)) { st2 = i; goto type2; } else ++z1; if (z1 > ans.fi) ans = {z1, x}; return ; type2: z1 = z2 = 0; for (int i = ne(l); i != r; i = ne(i)) if (i != st2) if (a[stk[i]] == a[stk[l]] + x * (z1 + 1)) ++z1; else if (a[stk[i]] == a[stk[st2]] + x * (z2 + 1)) ++z2; else goto type3; if (z1 != z2) goto type3; if (z1 > ans.fi) ans = {z1, x}; return ; type3: x = a[stk[ne(ne(l))]] - a[stk[l]], z1 = z2 = 0; for (int i = ne(ne(l)); i != r; i = ne(i)) if (a[stk[i]] == a[stk[l]] + x * (z1 + 1)) ++z1; else if (a[stk[i]] == a[stk[l + 1]] + x * (z2 + 1)) ++z2; else return ; if (z1 != z2) return ; if (z1 > ans.fi) ans = {z1, x}; } void rotcal() { for (int i = 1; i < n; ++i) if (area(a[0], a[i], a[i - 1]) != 0) goto not_line; return upd(0, n - 1); not_line:; for (int i = 0, j = 1, k = 1; i < top; ++i) { PLL x = a[stk[i]], y = a[stk[i + 1]]; j = k; while (area(x, y, a[stk[j]]) < area(x, y, a[stk[j + 1]])) j = ne(j); k = j; while (ne(k) != j && area(x, y, a[stk[k]]) == area(x, y, a[stk[k + 1]])) k = ne(k); upd(j, k); } } void get_b() { if (!ans.fi) for (int i = 0; i < n; ++i) b.pb(i + 1); else for (int i = 0; i < n; ++i) if (ha.find(a[i] - ans.se) == ha.end()) b.pb(ha[a[i]]); } signed main() { scanf("%d", &n); for (int i = 0; i < n; ++i) scanf("%lld %lld", &a[i].fi, &a[i].se); for (int i = 0; i < n; ++i) ha[a[i]] = i + 1; convex(a, n), rotcal(), get_b(); printf("%ld\n", b.size()); for (int i : b) printf("%d ", i); printf("\n%lld %lld\n%d\n", ans.se.fi, ans.se.se, ans.fi); return 0; }
|