2.8
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 using namespace std; 5 typedef long long LL; 6 7 // template 8 struct Point 9 { 10 LL x, y; 11 Point(LL x = 0, LL y = 0): x(x), y(y){} 12 }; 13 typedef Point Vector; 14 Vector operator - (Vector A, Vector B){return Vector(A.x - B.x, A.y - B.y);} 15 Vector operator + (Vector A, Vector B){return Vector(A.x + B.x, A.y + B.y);} 16 bool operator < (const Point& a, const Point& b){return a.x < b.x || (a.x == b.x && a.y < b.y);} 17 LL Cross(Vector A, Vector B){return A.x * B.y - A.y * B.x;} 18 19 LL PolygonArea(Point* P, int n) 20 { 21 LL ans = 0; 22 for(int i = 1; i < n - 1; i++) ans += Cross(P[i] - P[0], P[i+1] - P[0]); 23 return ans; 24 } 25 26 int ConvexHull(Point* p, int n, Point* ch) 27 { 28 sort(p, p + n); 29 int m = 0; 30 for(int i = 0; i < n; i++) 31 { 32 while(m > 1 && Cross(ch[m-1] - ch[m-2], p[i] - ch[m-2]) <= 0) m--; 33 ch[m++] = p[i]; 34 } 35 int k = m; 36 for(int i = n - 2; i >= 0; i--) 37 { 38 while(m > k && Cross(ch[m-1] - ch[m-2], p[i] - ch[m-2]) <= 0) m--; 39 ch[m++] = p[i]; 40 } 41 if(n > 1) m--; 42 return m; 43 } 44 45 Point p[5555], ch[5555]; 46 bool judge(int i, int j, int pos, int cnt) 47 { 48 p[0] = ch[i], p[1] = ch[j]; 49 p[2] = ch[pos]; 50 LL s1 = PolygonArea(p, 3); 51 p[2] = ch[(pos+1)%cnt]; 52 LL s2 = PolygonArea(p, 3); 53 return s2 > s1; 54 } 55 56 int main(void) 57 { 58 int n; 59 LL S; 60 scanf("%d %I64d", &n, &S); 61 for(int i = 0; i < n; i++) 62 { 63 int a, b; 64 scanf("%d %d", &a, &b); 65 p[i].x = (LL) a, p[i].y = (LL) b; 66 } 67 int cnt = ConvexHull(p, n, ch); 68 int a, b, c, pos; 69 LL s = 0; 70 for(int i = 0; i < cnt; i++) 71 { 72 pos = (i + 2) % cnt; 73 for(int j = (i + 1) % cnt; (j + 1) % cnt != i; j = (j + 1) % cnt) 74 { 75 if(pos == j) pos = (pos + 1) % cnt; 76 while((pos + 1) % cnt != i && judge(i, j, pos, cnt)) pos = (pos + 1) % cnt; 77 p[0] = ch[i], p[1] = ch[j], p[2] = ch[pos]; 78 LL tmp = PolygonArea(p, 3); 79 if(tmp > s) s = tmp, a = i, b = j, c = pos; 80 } 81 } 82 Point x = ch[a] + ch[b] - ch[c], y = ch[c] + ch[a] - ch[b], z = ch[b] + ch[c] - ch[a]; 83 printf("%I64d %I64d\n", x.x, x.y); 84 printf("%I64d %I64d\n", y.x, y.y); 85 printf("%I64d %I64d\n", z.x, z.y); 86 return 0; 87 }
Aguin
时间: 2024-11-03 01:28:53