main.cc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include <cmath>
  2. #include <cstdio>
  3. #define Vector Point
  4. using namespace std;
  5. const int N = 15;
  6. struct Point {
  7. double x;
  8. double y;
  9. Point(double x = 0, double y = 0) : x(x), y(y){};
  10. } point[N];
  11. double operator^(const Vector &v1, const Vector &v2) {
  12. return v1.x * v2.y - v1.y * v2.x;
  13. }
  14. Vector operator-(const Vector &v1, const Vector &v2) {
  15. return Vector(v1.x - v2.x, v1.y - v2.y);
  16. }
  17. Vector operator+(const Vector &v1, const Vector &v2) {
  18. return Vector(v1.x + v2.x, v1.y + v2.y);
  19. }
  20. Vector operator*(double k, const Vector &v) { return Vector(k * v.x, k * v.y); }
  21. int which_side(const Vector &v1, const Vector &v2) {
  22. double res = v1 ^ v2;
  23. if (res == 0) return 0;
  24. if (0 < res) return 1;
  25. return -1;
  26. }
  27. double area_of(const Vector &v1, const Vector &v2) { return fabs(v1 ^ v2) / 2; }
  28. int main() {
  29. int n;
  30. char p1, p2, p3, str[2];
  31. while (scanf("%d", &n) != EOF) {
  32. if (n == 0) break;
  33. double max_area = 0;
  34. for (int i = 0; i < n; i++)
  35. scanf("%s %lf %lf", str, &point[i].x, &point[i].y);
  36. for (int i = 0; i < n - 2; i++) {
  37. for (int j = i + 1; j < n - 1; j++) {
  38. for (int k = j + 1, side, l; k < n; k++) {
  39. Point &a = point[i];
  40. Point &b = point[j];
  41. Point &c = point[k];
  42. Vector v1 = c - a, v2 = a - b, v3 = b - c;
  43. side = ((a - b) ^ (c - b)) < 0 ? -1 : 1;
  44. for (l = 0; l < n; l++) {
  45. if (l == i || l == j || l == k) continue;
  46. Point &p = point[l];
  47. int s1 = which_side(v1, p - a);
  48. int s2 = which_side(v2, p - b);
  49. int s3 = which_side(v3, p - c);
  50. if ((s1 == 0 || s1 == side) && (s2 == 0 || s2 == side) &&
  51. (s3 == 0 || s3 == side))
  52. break;
  53. }
  54. if (l < n) continue;
  55. double area = area_of(a - b, c - b);
  56. if (max_area < area) {
  57. max_area = area;
  58. p1 = 'A' + i;
  59. p2 = 'A' + j;
  60. p3 = 'A' + k;
  61. }
  62. }
  63. }
  64. }
  65. printf("%c%c%c\n", p1, p2, p3);
  66. }
  67. return 0;
  68. }